1

I am trying to get Google Maps markers to appear in IE 8 and 9. Here's where I believe the problem lies:

var addresses = mapAddresses;
//alert(addresses);
if (addresses != null)
{
    var marker, x;
    var infowindow = new google.maps.InfoWindow();

    for (x = 0; x < addresses.length; x++) {
        //alert(addresses.length);
        //alert('http://maps.googleapis.com/maps/api/geocode/json?address=' + addresses[x]);
        $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address=' + addresses[x] + '&sensor=false', null, function (data) {

            var p = data.results[0].geometry.location
            //alert(data.results[0].formatted_address);  // This will alert the individual addresses.

            var latlng = new google.maps.LatLng(p.lat, p.lng);
            var marker = new google.maps.Marker({
                position: latlng,
                map: map,
                title: data.results[0].formatted_address
            });

            // Add the markers to the gmarkers array.
            gmarkers.push(marker);  //<-------- No markers appear to be getting in here.
        });            
    }

    geoCodeAddress(map);
}

I can see the markers in IE 10+, FF, and Chrome. I do not see any js errors in the debugger indicating something wrong. I verified that the $.getJSON() call returns results. Any help is appreciated. Thanks!

byronem
  • 39
  • 2
  • 1
    I was summoned here via the close-question flag, so I'm not an expert in this field. Just so you know, this is a very difficult question to answer because it focuses on such a specific behavior. Verify that the markers are compatible with older browsers. If they should be, I've voted this question up in the hope that someone will be able to help you with this rather arcane detail. – Dustin Apr 08 '15 at 16:27
  • Thanks for the comment, Dustin. As far as I can tell from the Google Maps API docs, the markers *should* work. The Google Maps JavaScript API v3 supports the following web browsers: For desktop: Internet Explorer 8–11 inclusive (Windows) The current and previous version of Firefox (Windows, Mac OS X, Linux) The current and previous version of Chrome (Windows, Mac OS X, Linux) The current and previous version of Safari (Mac OS X) – byronem Apr 08 '15 at 18:01

1 Answers1

1

After trying it on a windows XP.. it turns out that is is not the Google Maps, I mean I can add marker statically. In stead, I realized that it is actually the problem of the CORS on IE 8 + 9.

As you can see in the caniuse.com, IE 8 and IE 9 has only a partial support on CORS. Also it is said in the wiki that:

Internet Explorer did not implement CORS until version 10. The two previous versions (8 and 9) offered similar functionality through the XDomainRequest API. It is now supported by all modern browsers (desktop and mobile)

There are discussions saying that using jQuery.support.cors = true; would make it works, but sadly no luck for my Windows XP + IE 8.

Some more helpful readings:
'jQuery.getJSON' not working in Internet Explorer 8
jQuery issue in Internet Explorer 8

Community
  • 1
  • 1
kaho
  • 4,746
  • 1
  • 16
  • 24