如何收集我们正在通过谷歌绘图 API 绘制的多边形形状的每个边缘的纬度和经度。请帮我把我放在收集多边形边缘的完美路径上。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title> Region Drawing System</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=drawing,geometry&sensor=false"></script>
<script>
var infoWindow;
var contentString;
function initialize() {
var mapOptions = {
center : new google.maps.LatLng(42.397, -100.000),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
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.POLYGON
]
},
polygonOptions :{
editable: true,
draggable: true
}
});
drawingManager.setMap(map);
google.maps.event.addListener(drawingManager, 'click', showNewPath); // Passing drawingManager object is a good idea to collect edges of Polygon ?
infoWindow = new google.maps.InfoWindow();
}
function showNewPath() {
var contentString = " " //How to collect the edges of Polygon ?
infoWindow.setContent(contentString);
infoWindow.setPosition(); // How to specify the position for each edge ?
infowindow.open(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<center>
<h1> Region Drawing System</h1>
<div id="map-canvas" style="height:400px ; width:800px"></div>
<hr/>
<div id="panel">
<input id="address" type="textbox" value="">
<input type="button" value="Look UP" >
</div>
</center>
</body>
</html>