2

I found an answer for how to get the latitude and longitude for each point of the polygon here:

Polygon Drawing and Getting Coordinates with Google Map API v3

This appeared to work when I implemented it, however is no longer working, and I get the error:

"Error: TypeError: polygon.overlay.latLngs.b is undefined"

This is my code:

function polygonPoints(polygon) {
    var polygonPointsArray = [];

    $.each(polygon.overlay.latLngs.b[0].b, function(key, latlng){
            var lat = latlng.d;
            var lon = latlng.e;

            polygonPointsArray.push(lat+' '+lon); //do something with the coordinates
    });
}

Any help would be greatly appreciated.

Thanks

Matt

Community
  • 1
  • 1
user3469947
  • 23
  • 1
  • 1
  • 3

2 Answers2

2

That failed because polygon internal structure changed which happens from time to time.

How to get latitude and longitude of polygon points is described in this google example.

Anto Jurković
  • 11,188
  • 2
  • 29
  • 42
0

I had this problem as well - the quick fix for me was to change

$.each(polygon.overlay.latLngs.b[0].b, function(key, latlng){

to

$.each(polygon.overlay.latLngs.j[0].j, function(key, latlng){