MylesRip
MylesRip

Reputation: 1352

Polyline and polygon not showing in Google Maps for IE8 or IE7

I am drawing polylines and polygons on Google Maps. They show up correctly in Internet Explorer 9, but not in IE8 or IE7. I have come across a few posts that talk about a "hanging comma" problem with arrays that was fixed in IE9, and it might be related to the problem I'm having, but I don't see how I would run into that situation because of how my code works. I create "google.maps.LatLng" objects and "push" them into an array. I pass the array as the "path" parameter in creating a "google.maps.Polygon" object. I don't have any code that builds the array by inserting commas between items in a list.

var polygonPoints = new Array();

var point1 = new google.maps.LatLng(myLat1, myLong1); 
polygonPoints.push(point1);
var point2 = new google.maps.LatLng(myLat2, myLong2); 
polygonPoints.push(point2);
var point3 = new google.maps.LatLng(myLat3, myLong3); 
polygonPoints.push(point3);

var myPolygon = new google.maps.Polygon({
    path: polygonPoints,
    strokeColor: "#FFFF00",
    strokeOpacity: 1.0, strokeWeight: 2, 
    fillOpacity: 0.0
});

How can I get the polygon to show in IE8 and IE7? (Polylines don't show either, but markers do.)

Upvotes: 1

Views: 2630

Answers (2)

vantrung126
vantrung126

Reputation: 1


Now it works in IE7 and IE8 as well as most other browsers. Hopefully this will be helpful to someone else!


hi MylesRip ! I load google map in iframe, but i can't load polygon. In case, I not use iframe, it work normaly. The reason I use iframe because I need to avoid broken map when print

  • I used your way but does not work

== I write EN quite bad.

Upvotes: 0

MylesRip
MylesRip

Reputation: 1352

This took some experimentation, but I figured it out. The fix was to change the following line:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

to this:

<!DOCTYPE html>

Now it works in IE7 and IE8 as well as most other browsers. Hopefully this will be helpful to someone else!

Upvotes: 1

Related Questions