Jquery Google Maps Problem
Posted
by Matias
on Stack Overflow
See other posts from Stack Overflow
or by Matias
Published on 2010-04-11T17:59:29Z
Indexed on
2010/04/11
18:03 UTC
Read the original article
Hit count: 178
jQuery
|google-maps
Here is the problem:
Lets say a Jquery toggle button which loads a Google Map upon request and hides its later when toggled:
$('#showmeMap').toggle(function()
{
var map = new GMap2($("#map").get(0));
var mapCenter = new GLatLng(-2, 20);
map.setCenter(mapCenter, 12);
$('#map').show();
}
}, function() {
$('#map').hide();
});
Then I add some random markers and later another function which removes markers from the map:
$('#destroyMarkersButton').click(function() {
for (var i=0; i<gmarkers.length; i++)
{
map.removeOverlay(gmarkers[i]);
}
});
When clicking on the button I´ve got the error Map is undefined. My thought was defining Google Map object globally:
map = new GMap2($("#map").get(0));
Which works perfectly in Firefox, however, map fails to load on internet explorer!!
Any suggestions ?
© Stack Overflow or respective owner