I'm having an issue creating a markers in Google Maps.
I have a function in JS that getting a long string
locationlist look like that: "[{"Lat":"34.163291","Lng":"-118.685123"},{"Lat":"38.91992","Lng":"-76.992757"},{"Lat":"39.309265","Lng":"-76.749287"},{"Lat":"40.658113","Lng":"-74.005874"},{"Lat":"33.837814","Lng":"-117.886568"}]" ...... (Long String)
For each Lat,Lng in this string I want to create a marker and display it on the map Hope that someone can help me with that.
Also does it going to effect the speed that the map will load?? when loading bunch of markers at once!
JS Funcation:
var locationObj;
var historyObj;
function setMap(locationList) {
// List of Lat,Lng
locationObj = $.parseJSON(locationList);
//Looping through the Object
for (i in locationObj) {
var LatLngPair = new google.maps.LatLng(locationObj[i]["Lat"], locationObj[i]["Lng"]);
// Getting the Lat,Lng frmo the object
var hItem = locationObj[i];
var qLat = parseFloat(hItem["Lat"]);
var qLong = parseFloat(hItem["Lng"]);
var qMapTypeId = google.maps.MapTypeId.SATELLITE
var myLatlng;
if (qLat != 0 && qLong != 0) {
myLatlng = new google.maps.LatLng(qLat, qLong);
mapOptions = {
zoom: 1,
center: myLatlng,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
}
}
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
map.setTilt(45);
map.setHeading(0);
map.setMapTypeId(qMapTypeId);
var marker = new google.maps.Marker({
position: myLatlng,
map: map
});
google.maps.event.addListener(marker, "click", function (event) {
});
}
}
$("#map-canvas").show();
$("#divLoadingMessageMap").css("display", "none");
}