calling function from onload doesnt work
Posted: Sat Jul 07, 2007 11:37 am
Hi there,
I am encoutering a weird problem,
I call this function on the body onload event
and test() function is just
map is declared globaly.
My problem is that the function test() shows 0 when run from within the onload function, but when i assign it to a click of a button it shows the proper ammount of markers produced by the request_markers() function...
Why is this happening?
Thanks
I am encoutering a weird problem,
I call this function on the body onload event
Code: Select all
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(37.97242, 23.728), 6);
map.markers=[];
request_markers();
GEvent.addListener(map, 'zoomend', function() {
drawMarkers(filteredMarkers(map.markers));
});
test();
}
}Code: Select all
function test(){
alert(map.markers.length);
}My problem is that the function test() shows 0 when run from within the onload function, but when i assign it to a click of a button it shows the proper ammount of markers produced by the request_markers() function...
Why is this happening?
Thanks