I have a problem with the markers in the map of google maps, I have been trying to implement a google map with javascript api, I work with ionic 1 and angularjs and this is the code I have so far. The problem is that it only marks me where I am and does not show me the markers of the stores that I get with the json.
Javascript and Cordova geolocalization
var options = {
timeout: 10000,
enableHighAccuracy: true
};
$cordovaGeolocation.getCurrentPosition(options).then(function(position) {
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var mapOptions = {
center: latLng,
zoom: 17,
disableDefaultUI: true
};
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var marker = new google.maps.Marker({
position: latLng,
map: map,
});
// To add the marker to the map, call setMap();
marker.setMap(map);
}, function(error) {
console.log("Could not get location");
});
$.getJSON("http://www.kupomcity.com/gamma/api_v2.php?_opt=comercios&_act=json", function(json1) {
$.each(json1, function(key, data) {
//console.log (data);
if (data.lat != '' && data.lng != '') {
console.log("json lat: " + data.lat + "json lng: " + data.lng);
var latLng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: latLng,
});
marker.setMap($scope.map);
};
});
})