Google maps 谷歌地图获取地区名称

Google maps 谷歌地图获取地区名称,google-maps,Google Maps,我无法从谷歌地图地理编码器(在地形模式下)中提取自然区域的标题。我只能显示结果[0]中最近道路的名称(红色箭头)。有没有办法提取地图上显示的最近的标题(绿色箭头)?它在结果数组中可用吗 var latlng = {lat: parseFloat(lat), lng: parseFloat(lng)}; var geocoder = new google. maps. Geocoder; geocoder. geocode({'location': latlng}، function(re

我无法从谷歌地图地理编码器(在地形模式下)中提取自然区域的标题。我只能显示结果[0]中最近道路的名称(红色箭头)。有没有办法提取地图上显示的最近的标题(绿色箭头)?它在结果数组中可用吗

var latlng = {lat: parseFloat(lat), lng: parseFloat(lng)};    
var geocoder = new google. maps. Geocoder;
geocoder. geocode({'location': latlng}، function(results، status) {
if (status === 'OK') {
   if (results[0]) {
   $("#place"). val(results[0]. formatted_address);
   } else {
   //No title found
   }
   } else {
   //window. alert('Geocoder failed due to: ' + status);
  }
});

这是对谷歌地图结果的回应,在地址组件中,您有一个地区或地区的标题 我想您需要这个
结果[0]。地址\u组件[2]

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1600",
               "short_name" : "1600",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Amphitheatre Pkwy",
               "short_name" : "Amphitheatre Pkwy",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Mountain View",
               "short_name" : "Mountain View",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santa Clara County",
               "short_name" : "Santa Clara County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "California",
               "short_name" : "CA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "94043",
               "short_name" : "94043",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
         "geometry" : {
            "location" : {
               "lat" : 37.4224764,
               "lng" : -122.0842499
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 37.4238253802915,
                  "lng" : -122.0829009197085
               },
               "southwest" : {
                  "lat" : 37.4211274197085,
                  "lng" : -122.0855988802915
               }
            }
         },
         "place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}

谢谢你展示了完整的阵列。不幸的是,没有一个字段包含我要查找的名称!对不起,我没有为你找到更多的东西:(