我正在开发一个应用程序,我需要通过矩形选择区域并将其放在西南和东北输入中,以便将它们存储在我的数据库中这是我的代码,请我需要帮助...
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
margin: 0;
padding: 0;
width: 500px;
height: 500px;
left;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
//var bounds;
function updateRectanglePosition(rectangle) {
var point1 = this.getBounds().getNorthEast();
var point2 = this.getBounds().getSouthWest();
document.getElementById('lat1').value = point1.Lat();
document.getElementById('lng1').value = point1.Lng();
document.getElementById('lat2').value = point2.Lat();
document.getElementById('lng2').value = point2.Lng();
}
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(44.490, -78.649),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var Bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(44.490, -78.649),
new google.maps.LatLng(44.599, -78.443)
);
var rectangle = new google.maps.Rectangle({
bounds: Bounds,
draggable: true,
editable: true,
map : map,
});
rectangle.setMap(map);
updateRectanglePosition(rectangle);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
<div id="aa">
<form action="" method="post">
<p>
<label>longitude1</label>
<input type="text" id="lng1" name="lng1"/>
<label>latitude1</label>
<input type="text" id="lat1" name="lat1"/>
</p>
<p>
<label>longitude2</label>
<input type="number" id="lng2" name="lng2"/>
<label>latitude2</label>
<input type="number" id="lat2" name="lat2"/>
</p>
<p>
<input type="submit" name="ajouter" id="ajouter" value="ajouter"/>
</p>
</form>
</div>
<b id="output"></b>
</body>
</html>
请帮助...我真的需要它来在我的训练中取得好成绩