I am trying to create markers from a database. I do this by outputting the DB results to json and loading the json in the google maps code. The JSON is valid and is being loaded.
My full Google maps code is:
google.load("maps", "2");
// make a json request to get the map data from the Map action
$(function() {
if (google.maps.BrowserIsCompatible()) {
$.getJSON("/GoogleMaps/Map", initialise);
}
});
function initialise(mapData) {
var map = new google.maps.Map2($("#map")[0]);
map.addControl(new google.maps.SmallMapControl());
map.addControl(new google.maps.MapTypeControl());
map.setMapType(G_SATELLITE_MAP);
var latlng = new google.maps.LatLng(52.370, 4.893);
var zoom = 8;
map.setCenter(latlng, zoom);
map.setCenter(latlng, zoom);
$.each(mapData.locations, function(i, location) {
setupLocationMarker(map, location);
});
}
function setupLocationMarker(map, location) {
console.debug(location.LatLng);
var latlng = new google.maps.LatLng(location.LatLng);
var marker = new google.maps.Marker(latlng);
map.addOverlay(marker);
}
The JSON:
{
"locations": [
{
"Id": 1,
"Name": null,
"LatLng": "52.368, 4.806",
},
{
"Id": 2,
"Name": null,
"LatLng": "52.333, 4.839",
},
Ive tried debugging with Firebug but I get no errors. The coordinates seem to load just fine. But only 1 marker shows up, and that marker isn't actually attached to any coordinates it seems (if you zoom out it doesn't ajust). Also the map is very slow at this point. Does anyone know how to solve this?