PDA

View Full Version : Can't initialize array in IE (FF okay)


webnick2008
02-11-2008, 06:44 AM
Hi, This seems to be working fine in FF but throws an error in IE7. I create an array in my function and then use it in other functions. It's global but IE doesn't like something about the syntax??

You can see the first marker doesn't set up on the map but, after clicking show/hide, it actually throws the error.

http://www.strans.org/hotspots/t.phpfunction pageInit()
{ // set up map and stuff
map = new Map('mapContainer', 'geography', 'Missoula, MT', 6); // Create and display Map object at address with zoom level. Include your application ID.
map.addTool(new PanTool(), true); // Make the map draggable
map.addWidget(new SatelliteControlWidget()); // Add Widgets to the map and display them

marker = []; // Create a marker object, then add the POI marker to the map
marker[1] = new CustomPOIMarker('Free Cycles', '', '732 S. 1st St W. <br />Missoula, MT 59801 <br /><br />Free Cycles Missoula is a volunteer <br />effort providing bikes, parts and help for <br />those in need. (406) 541-PATH', '', '');
map.addMarkerByAddress(marker[1], '732 S. 1st St. W., Missoula, MT 59801');

if(document.getElementById('addform'))
{
document.getElementById('mapContainer').style.height = '380px';
map.setZoomLevel(4);
}
else { // BIG map
map.addWidget(new NavigatorWidget());
map.addEventListener(Map.EVENT_INITIALIZE, mapMarkers); // addMarkers after map loads
hideLevels(); // close up the markers list
}
}

function moveMap( _levelId, location )
{// Recenter map if an address link is clicked on webpage
map.setCenterByAddress(location);
map.setZoomLevel(4);
marker[ _levelId ].open();
showLevel( _levelId, location );
pageTracker._trackPageview( '/hotspot/mapview/'+ _levelId +'/'+ location ); // hit google analytics
}

<a href="javascript:moveMap( '1227','S. Russell St. and S. 7th St., Missoula, MT' );">S. Russell St. and S. 7th St., Missoula, MT</a>

The error 'marker is null or not an object':function moveMap( _levelId, location ) ....
marker[ _levelId ].open();

Trinithis
02-11-2008, 07:21 AM
Either the pageInit hasn't been called or something dealing with _levelId.

I'm betting it's pageInit didn't get called for whatever reason. Are you using IE compliant event listeners?

webnick2008
02-13-2008, 07:51 AM
No, That doesn't seem to be it. That way of loading seems to be pretty pat. I checked and the marker length is 1... There's something else with IE, that it doesn't seem to ever really load the map. When I use the same Yahoo code (http://developer.yahoo.com/maps/flash/jsGettingStarted.html#marker)in my app, the map doesn't finish loading either.

More debugging to do, damnit. Thanks for your help though