【发布时间】:2014-03-26 00:27:38
【问题描述】:
我使用英特尔 XDK 创建了一个应用程序,用于确定地图上的当前位置。但是我找不到任何关于如何将纬度和经度转换为地址的文档或教程。有没有人有任何有用的链接或指导?
谢谢
【问题讨论】:
我使用英特尔 XDK 创建了一个应用程序,用于确定地图上的当前位置。但是我找不到任何关于如何将纬度和经度转换为地址的文档或教程。有没有人有任何有用的链接或指导?
谢谢
【问题讨论】:
Intel XDK 没有将lat/lng 转换为地址的API,还有其他反向地理编码服务,可以使用google maps 反向地理编码将纬度/经度转换为地址,更多信息here,示例如下:
包括谷歌地图 api 脚本:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
这里是反向地理编码方法:
function reverseGeocode(lat, lng){
var latlng = new google.maps.LatLng(lat, lng);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
alert(results[1].formatted_address);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
}
你可以通过运行获得地址:reverseGeocode(45, -122)
【讨论】:
formatted_address你可以得到其他属性developers.google.com/maps/documentation/geocoding