我有下一个获取多边形坐标的代码,但我想在画圆时获取中心坐标。
有谁知道如何实现这一目标?
最好的问候,并希望有人对此有所了解。
function draw() {
if (drawingManager <= 0) then
var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.POLYGON,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [
google.maps.drawing.OverlayType.MARKER,
google.maps.drawing.OverlayType.CIRCLE,
google.maps.drawing.OverlayType.POLYGON,
google.maps.drawing.OverlayType.POLYLINE,
google.maps.drawing.OverlayType.RECTANGLE
]
},
markerOptions: {
icon: 'images/beachflag.png'
},
polygonOptions: {
fillColor: '#1E90FF',
fillOpacity: 0.4,
strokeWeight: 2,
clickable: true,
editable: true,
zIndex: 1
}
});
var coord_listener = google.maps.event.addListener(drawingManager, 'polygoncomplete', function (polygon) {
var coordinates = (polygon.getPath().getArray());
alert(coordinates);
PassPolygonToField(coordinates);
window.poly = polygon;
});
drawingManager.setMap(map);
}
function PassPolygonToField(coordinates) {
//here I pass the coords to the form field and then I insert the form into a mysql database.
document.getElementById('myField').value = (coordinates);
}