繁体   English   中英

地理位置定位如何从随机字符串中获取地址

[英]Geolocation how to get address from random string

基本上,我会在Google地图中使用地理位置功能,以便将地址转换为坐标。

我了解如何执行此操作,但我能否使其正常工作,但这是基于用户输入的,因此,如果用户输入了诸如“ NW1 hello blabla”之类的随机信息,是否有可能获得Google Maps来读取字符串并注意到哪些单词是实际地址。

地理位置代码

var place =  "New York Hello"; // I want to enter any kind of string and have gmaps to understand it

geocoder = new GClientGeocoder();

geocoder.getLatLng(place, function(point) {  (!point) {

alert(place + " not found");
} else {

var info = "<h3>"+place+"</h3>Latitude: "+point.y+"  Longitude:"+point.x;

var marker = new GMarker(point);

map.addOverlay(marker);

marker.openInfoWindowHtml(info);
} });

这就是地址解析器的设计目的(获取看起来像地址的字符串并返回位置,而不是“随机”字符串)。 但是,如果用户输入垃圾,就会产生垃圾。 如果该字符串看起来像一个地址(并且有一个匹配的条目),则地理编码器将完成合理的工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM