【问题标题】:Use fields specifier for maps.googleapis?使用 maps.googleapis 的字段说明符?
【发布时间】:2017-12-03 19:44:01
【问题描述】:

我正在尝试从 maps.googleapis 调用中获取 json 返回的子集。具体是在下面当前返回的正文中的位置:

"location" : {
    "lat" : 44.0581728,
    "lng" : -121.3153096
}

如果我向:http://maps.googleapis.com/maps/api/geocode/json?address=bend&sensor=false 提出获取请求 结果如下:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Bend",
               "short_name" : "Bend",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Deschutes County",
               "short_name" : "Deschutes County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Oregon",
               "short_name" : "OR",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Bend, OR, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 44.1231839,
                  "lng" : -121.248579
               },
               "southwest" : {
                  "lat" : 43.999089,
                  "lng" : -121.3807099
               }
            },
            "location" : {
               "lat" : 44.0581728,
               "lng" : -121.3153096
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 44.1231839,
                  "lng" : -121.248579
               },
               "southwest" : {
                  "lat" : 43.999089,
                  "lng" : -121.3807099
               }
            }
         },
         "place_id" : "ChIJUdLTpf_AuFQRtNEgx6zniBA",
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

我尝试将 &fields=location 添加到 get 请求,但它返回相同的信息。我在https://developers.google.com/maps/documentation/geocoding/intro#GeocodingRequests 上没有看到明确的方法

任何帮助表示赞赏! 谢谢!

【问题讨论】:

    标签: json google-maps get google-geocoding-api


    【解决方案1】:

    您需要的位置存在于几何体中。 JSON 对象在几何字段下具有位置属性。

    【讨论】:

    • 谢谢。我只希望 get 请求返回位置,所以我没有解析它。我不确定如何在获取请求中指定它..
    猜你喜欢
    • 2020-10-08
    • 1970-01-01
    • 2017-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多