What causes a Google Maps error in IE8?

We use Google Maps and have identified a problem that appears to occur only in IE8 (and possibly below). Functionality works correctly in FF, Chrome, IE9.

Code that occurs with an error:

google.load("maps", "3.x", { other_params: "sensor=false" });
    var mapdiv = null;
    $(function () {
        mapdiv = document.getElementById("map");
        map = new google.maps.Map( mapdiv, {
            zoom: 1,
            center: new google.maps.LatLng(6, 35),
            disableDefaultUI: true,
            mapTypeId: google.maps.MapTypeId.TERRAIN
        });
        var latlngbounds = new google.maps.LatLngBounds( );

In particular, on this line:

map = new google.maps.Map( mapdiv, {
    zoom: 1,
    center: new google.maps.LatLng(6, 35),
    disableDefaultUI: true,
    mapTypeId: google.maps.MapTypeId.TERRAIN
});

and error:

The object does not support this property or method.

I had a little game with IE dev tools, and if I replaced map =it with something like var x =, then some error, so it makes me think that the object mapis the culprit that some property / method is missing. Although I really don't know where the object comes from map, I assume that it is loading from a call google.load.

Does anyone know what is going on here?

+5
1

:

map = new google.maps.Map(mapdiv, { zoom: 1, center: new google.maps.LatLng(6, 35), disableDefaultUI: true, mapTypeId: google.maps.MapTypeId.TERRAIN });

, JavaScript , map. , .. var map = ..., .

map window.map, a div . , window.map google.maps.Map. - , , IE8 , , DOM.

:

  • var map
  • div map .
  • map, window.map =...

    (3b) , window.map, . myMap = new google.maps.Map(...

+9

All Articles