Google Maps v3 Object is null or undefined-Collection of common programming errors
I am getting “Unable to get value of the property ‘3’: object is null or undefined” at this line of code in IE7 and IE8 and don’t know how to solve it. Any help greatly appreciated.
marker = new google.maps.Marker
I’m not sure what it means by undefined as I have declared the variable in the previous code block. Any help greatly appreciated…http://jsfiddle.net/svuce/1/
function initialize() {
var markers = new Array();
var locations = [
['Donegal', 'Some text goes here
text', 'walking', -33.900542, 151.174856],
['Bondi Beach', 'Some text goes here
text', 'walking', -33.890542, 151.274856],
['Coogee Beach', 'Some text goes here
text', 'golfing', -33.923036, 151.259052],
['Cronulla Beach', 'Some text goes here
text', 'family', -34.028249, 151.157507],
['Manly Beach', 'Some text goes here
text', 'explore', -33.80010128657071, 151.28747820854187],
['Maroubra Beach', 'Some text goes here
text', 'cycling', -33.950198, 151.259302],
];
var map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][3], locations[i][4]),
map: map,
icon: 'images/map_'+locations[i][2]+'_image.png'
});
markers.push(marker);
var boxText = document.createElement("div");
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
boxText.style.cssText = "border: none 0; margin-top: 8px; background:#fff; padding: 8px;border:1px solid #877856;";
boxText.innerHTML = locations[i][0]+"
"+locations[i][2]+"
"+locations[i][1]+"";
$(".infobox-close").remove();
var myOptions = {
content: boxText
,disableAutoPan: false
,maxWidth: 0
,pixelOffset: new google.maps.Size(-140, -180)
,zIndex: null
,boxStyle: {
opacity: 1
,width: "280px"
}
,closeBoxMargin: "12px 7px 0 0"
,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
,infoBoxClearance: new google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
var ib = new InfoBox(myOptions);
ib.open(map, marker);
}
})(marker, i));
}
// == shows all markers of a particular category, and ensures the checkbox is checked ==
function show(category) {
for (var i=0; i
Originally posted 2013-11-10 00:12:41.