小编Ver*_*rma的帖子

如何通过google javascript api获取知道place_id的位置坐标

我知道place_id,我需要知道它的坐标.

我可以 GET https://maps.googleapis.com/maps/api/geocode/json?place_id=ChIJOwE7_GTtwokRFq0uOwLSE9g&key=KEY_GOES_HERE

这给了我这样的东西:

```   "results" : [
      {
         "address_components" : [...],
         "formatted_address" : "New York County, NY, USA",
         "geometry" : {
            "bounds" : {...},
            "location" : {
               "lat" : 40.7830603,
               "lng" : -73.9712488
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {...}
         },
         "partial_match" : true,
         "place_id" : "ChIJOwE7_GTtwokRFq0uOwLSE9g",
         "types" : [...]
      }
   ],
   "status" : "OK"
```
Run Code Online (Sandbox Code Playgroud)

但我需要通过javascript api来做.

我的页面上没有任何地图,只需要获取坐标.

google-maps google-maps-api-3 google-geocoder

5
推荐指数
2
解决办法
1万
查看次数