Google Maps API 3:从右键点击获取坐标 [英] Google Maps API 3: Get Coordinates from Right-Click
问题描述
我有一个Google地图的实时预览功能,可以运行。
我有2个文本框用于经纬度,用于当用户向db输入新记录时。很棒,现在我想要做的就是在地图上添加一个右键点击事件,点击坐标来填充纬度/经度文本框。
这甚至可能吗? ?
我知道如何添加事件侦听器,并查看API文档,但没有看到任何这样做。我知道你可以在他们的网站上的谷歌地图上做到这一点。 .event.addListener(map,rightclick,function(event){
var lat = event.latLng.lat();
var lng = event.latLng.lng();
//使用lat,lng
alert(Lat =+ lat +; Lng =+ lng);
});
I have 2 text boxes for lat and lon for when a user is entering a new record to the db.
I have a live preview of Google Maps that works great, now what I want to do is add a right-click event on the map that populates the lat/lon text boxes with the coord clicked.
Is this even possible?
I know how to add the event listener, and looked through the API docs, but didn't see anything that does this. I know you can do it on google's map on their website.
google.maps.event.addListener(map, "rightclick", function(event) {
var lat = event.latLng.lat();
var lng = event.latLng.lng();
// populate yor box/field with lat, lng
alert("Lat=" + lat + "; Lng=" + lng);
});
这篇关于Google Maps API 3:从右键点击获取坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!