I'm using Google Maps in order to display markers on a map. I make use of Markermanager out of Google Maps' utility library version 1.1 (http://gmaps-utility-library-dev.googlecode.com/svn/tags/markermanager/1.1/src/markermanager.js)
The script works perfectly in Firefox, Chrome and Opera, however in IE7 and IE8 the map shows up without markers. IE gives me an error:
'posn.0' is empty or no object googlemaps.js Code: 0 URI: mydomain.com/googlemaps.js
Googlemaps.js looks like:
var officeLayer = [
{
"zoom": [0, 1],
"places": [
{
"name": "USA",
"posn": [40.72, -73.9826]
},
{
"name": "Europe",
"posn": [52.370, 4.8966]
}
]
},
{
"zoom": [2, 17],
"places": [
{
"name": "Amsterdam",
"posn": [52.370, 4.8966]
},
{
"name": "Barcelona",
"posn": [41.388, 2.1833]
},
{
"name": "Berlin",
"posn": [52.5166, 13.4000]
},
{
"name": "New York City",
"posn": [40.72, -73.9826]
},
{
"name": "Paris",
"posn": [48.860, 2.3333]
}
]
},
{
"zoom": [9, 17],
"places": [
{
"name": "&klevering Centraal",
"posn": [52.379446, 4.893913]
},
{
"name": "290 Square Meters",
"posn": [52.368906, 4.902288]
}
]
}
];
var map;
var mgr;
var icons = {};
var allmarkers = [];
function getIcon(images) {
var icon = null;
if (images) {
if (icons[images[0]]) {
icon = icons[images[0]];
} else {
icon = new GIcon();
icon.image = "img/"
+ images[0] + ".png";
var size = iconData[images[0]];
icon.iconSize = new GSize(size.width, size.height);
icon.iconAnchor = new GPoint(size.width >> 1, size.height >> 1);
icon.shadow = "img/"
+ images[1] + ".png";
size = iconData[images[1]];
icon.shadowSize = new GSize(size.width, size.height);
icons[images[0]] = icon;
}
}
return icon;
}
function setupOfficeMarkers() {
allmarkers.length = 0;
for (var i in officeLayer) {
var layer = officeLayer[i];
var markers = [];
for (var j in layer["places"]) {
var place = layer["places"][j];
var icon = getIcon(place["icon"]);
var title = place["name"];
var posn = new GLatLng(place["posn"][0], place["posn"][1]);
var marker = createMarker(posn,title,icon);
markers.push(marker);
allmarkers.push(marker);
}
mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
}
mgr.refresh();
}
function createMarker(posn, title, icon) {
var marker = new GMarker(posn, {title: title, icon: icon, draggable:false });
return marker;
}
function reloadMarkers() {
setupOfficeMarkers();
}
You can see the script live at http://www.trendy-places.com/Amsterdam
I cannot find out what causes the error.
Thank you for your help in advance!
Check for the trailing comma in your places arrays. IE may be expecting another element and causing the error.