Using the Google Maps API Drawing Manager, I want to collect the location of each point in the polygon that is drawn by a user.
I know there is a getPath()
-
use it inside the polygoncomplete-callback.
example:
google.maps.event.addListener(drawingManager, 'polygoncomplete', function(polygon) {
drawingManager.setDrawingMode(null);
var arr=[];
polygon.getPath().forEach(function(latLng){arr.push(latLng.toString());})
alert(arr.join(',\n'));
});
it iterates over the path(using the forEach-method of a google.maps.MVCArray) and populates another array with the string-representations of the LatLng's
讨论(0)
- 热议问题