【问题标题】:How to get place Name of location from google.maps.Geocoder()?如何从 google.maps.Geocoder() 获取位置名称?
【发布时间】:2015-10-15 07:56:05
【问题描述】:

我想从 google Geocoder() 中命名位置。我在地图上有可拖动标记,当我拖动标记时,我们将通过以下代码获取标记的位置。 geocodePosition(marker.getPosition());

我可以获取位置的地址,但是如何获取位置的名称,例如,如果您将标记拖到像 white house 这样的知名建筑物上,它应该将位置名称命名为白宫

 var geocoder = new google.maps.Geocoder();
      function geocodePosition(pos){
         geocoder.geocode({
            latLng: pos
         }, function(responses){
            if (responses && responses.length >0){
              $scope.address=responses[0].formatted_address;
              $scope.name=responses[0].address_components[0].long_name;
            } else{
              $scope.address='Cannot determine address at this location';
            }
         });
      }

【问题讨论】:

    标签: javascript google-maps google-app-engine google-maps-api-3


    【解决方案1】:

    地理编码器用于将邮政地址转换为坐标。反向地理编码器执行相反的操作(将坐标转换为地址)。

    如果您需要地点名称(或者如果您想在地址中包含地点名称),您需要使用Places Library

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多