从标记返回地址

发布于 2024-12-04 05:13:02 字数 1307 浏览 0 评论 0原文

我对反向地理编码很陌生。我已经设法在地图上放置一个可拖动的标记,当放置该标记时,使用以下代码将纬度/经度返回到表单上的文本框:

div id="map" style="width: 600px; height: 467px"></div>

<script type="text/javascript" src="http://maps.google.com/maps? 
file=api&v=2&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></script>

<script type="text/javascript"> 
<!--
if (GBrowserIsCompatible()) 
{
// create map and add controls
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());        
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom();
//map.enableGoogleBar();

// set centre point of map
var centrePoint = new GLatLng('53.767789993998804', '-2.7046966552734375');
map.setCenter(centrePoint, 10); 

// add a draggable marker
var marker = new GMarker(centrePoint, {draggable: true});
map.addOverlay(marker);

// add a drag listener to the map
GEvent.addListener(marker, "dragend", function() {
var point = marker.getPoint();
map.panTo(point);
document.getElementById("latitude").value = point.lat().toFixed(5);
document.getElementById("longitude").value = point.lng().toFixed(5);

});
}

</script>

这很好用,但我也想将街道名称捕获到文本框中,但我迷路了。我知道我不能使用“点”来做到这一点,并且必须定义一个函数,但我完全迷失了,谷歌搜索对于像我这样开始的人来说没有任何用处。

任何指示将不胜感激。

谢谢

I'm very new to reverse geocoding. I have managed to place a dragable marker on a map which when dropped returns the Lat/Long to text boxes on a form using the code below:

div id="map" style="width: 600px; height: 467px"></div>

<script type="text/javascript" src="http://maps.google.com/maps? 
file=api&v=2&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></script>

<script type="text/javascript"> 
<!--
if (GBrowserIsCompatible()) 
{
// create map and add controls
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());        
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom();
//map.enableGoogleBar();

// set centre point of map
var centrePoint = new GLatLng('53.767789993998804', '-2.7046966552734375');
map.setCenter(centrePoint, 10); 

// add a draggable marker
var marker = new GMarker(centrePoint, {draggable: true});
map.addOverlay(marker);

// add a drag listener to the map
GEvent.addListener(marker, "dragend", function() {
var point = marker.getPoint();
map.panTo(point);
document.getElementById("latitude").value = point.lat().toFixed(5);
document.getElementById("longitude").value = point.lng().toFixed(5);

});
}

</script>

This works fine but I would also like to capture the street name to a text box but am lost. I know I can't do it using 'point' and have to define a function but am completely lost and google searches have turned up nothing of use to someone starting out like me.

Any pointers would be appreciated.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖微凉心微凉 2024-12-11 05:13:02

我想答案就在这里:
http://code.google.com/apis/maps/documentation /javascript/services.html#ReverseGeocoding

但您需要升级到 Google Maps API 版本 3。

I reckon the answer is here:
http://code.google.com/apis/maps/documentation/javascript/services.html#ReverseGeocoding

But you'll need to upgrade to version 3 of Google Maps API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文