我會從openlayers地圖獲取座標。 當我打開我的頁面時,當我點擊一個按鈕時,我收到了左上角和右上角的座標。[Javascript]從openlayers地圖獲取座標
<html>
<head>
<title>OpenLayers Example</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'});
map.addLayer(wms);
map.zoomToMaxExtent();
</script>
<input type="button" text="Get Coordinate from map">
</body>
</html>
非常感謝。
你可以使用.toBBOX()來獲得一個字符串版本的界限,並且你可以使用任何標準的Javascript方法來生成你的按鈕。 – 2010-06-25 00:36:20