(这是我到公司研究的第一个东东,呵呵)
拖动标点 即可弹出该标点落点的经纬度
鼠标点击地图 也可以取出点击处的经纬度
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<TITLE>WMI Scripting HTML</TITLE>
<script src="http://ditu.google.cn/maps?file=api&v=2&key=abcdefg&hl=zh-CN"
type="text/javascript"></script>
<script>
var map;
var center;
function initialize()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("gmap"));
map.addControl(new GSmallMapControl());
map.enableGoogleBar();
map.addControl(new GMapTypeControl());
center = new GLatLng(29.557,106.567);
map.setCenter(center, 12);
marker = new GMarker(center, {draggable: true});
GEvent.addListener(marker, "dragend", function(point) {
alert("标点现在的经纬度是:" + point);
});
GEvent.addListener(map, "click", function(o, p) {
alert("您点击的位置的经纬度是:" + p);
});
map.addOverlay(marker);
}
//document.getElementById("gmap").style.visibility = "false";
}
function Button1_onclick() {
var center = map.getCenter();
marker.setLatLng(center);
alert("当前中心的经纬度是:"+center);
}
</script>
</HEAD>
<body>
<div id = "gmap" style="position:absolute; z-index
9998; width: 780px; height: 420px; left: 23px; top: 20px;">
</div>
<input id="Button1" type="button" value="标点置中" style="z-index:999996;position:relative; left: 22px; top: 443px; width: 76px; height: 25px; color: red;"
/>
</body>
</HTML>