【问题标题】:Intel XDK Geocoding英特尔 XDK 地理编码
【发布时间】:2014-03-26 00:27:38
【问题描述】:

我使用英特尔 XDK 创建了一个应用程序,用于确定地图上的当前位置。但是我找不到任何关于如何将纬度和经度转换为地址的文档或教程。有没有人有任何有用的链接或指导?

谢谢

【问题讨论】:

    标签: intel intel-xdk


    【解决方案1】:

    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)

    【讨论】:

    • 您知道英特尔 xdk 是否可以利用设备的传感器功能并通过摇动设备来获取其当前地址?我在网上找不到任何东西
    • 谢谢...你知道我怎样才能让这个也显示街道名称吗?
    • 这里是地理编码器的更多细节,而不是formatted_address你可以得到其他属性developers.google.com/maps/documentation/geocoding
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    相关资源
    最近更新 更多