当用户点击地图时,是否有人知道默认的Google地图界面如何显示信息窗口中的长和lat坐标?
标题代码:
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=..." type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(13.175771, -59.556885), 10);
map.setUIToDefault();
}
}
</script>
正文代码:
<div id="map" style="width: 640px; height: 300px"></div>
答案 0 :(得分:12)
google.maps.event.addListener(map, 'click', function(event) {
new google.maps.InfoWindow({
position: event.latLng,
content: event.latLng.toString()
}).open(map);
});