I am trying to create tokens from a database. I do this by outputting DB results to json and loading json into google map code. JSON is valid and loading.
My full google maps code:
google.load("maps", "2");
$(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);
}
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. Most likely, the coordinates are loading. But only 1 marker appears, and this marker is not really attached to any coordinates (if you zoom out, itβs not). Also at the moment the card is very slow. Does anyone know how to solve this?
source
share