How to get place or placeid by latLng in android using google places api?

强颜欢笑 提交于 2019-12-12 06:00:19

问题


How to get place or placeid by latLng in android using google places api ? I want to get place or placeid when i get latLng


回答1:


you can use this Google Maps API

http://maps.googleapis.com/maps/api/geocode/json?latlng=23.00,72.57&sensor=true



回答2:


I have implemented in my application using this way

https://maps.googleapis.com/maps/api/geocode/json?latlng=21.1702401,72.8310607&key=YOUR_API_KEY

u will get Response like this which contains place_id.

{
   "results" : [
      {
         "address_components" : [
           //It contains postal code and details
         ],
         "formatted_address" : "22 Demart, Surat, India,
         "geometry" : {
            "location" : {
               "lat" : 21.1702401,
               "lng" : 72.8310607
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 21.1702401,
                  "lng" : 72.8310607
               },
               "southwest" : {
                  "lat" : 21.1702401,
                  "lng" : 72.8310607
               }
            }
         },
         "place_id" : "ChIJd8BlQ2BZwokRAFUEcm_qrcA",
         "types" : [ "street_address" ]
      },

   ... Additional results truncated in this example[] ...

   ],
   "status" : "OK"
}

you can refer this link also

https://developers.google.com/maps/documentation/geocoding/start

Hope this will help u..u can ask if any question




回答3:


Both of the proposed ways - cost money and I think peoples should mention it. Yes, we have the -$200 from the Google, but its all depends from how much users you have and how frequent you need to use the geocoder. 60k requests per month to the geocoder - easy $300 only for to use the geocoder :

Nov 1 – 30, 2018 Geocoding API Geocoding: 6073 Counts - $30.38

Dont filter what you need in the responses, like we have in the requests from other posts? Expect way more:

Nov 1 – 30, 2018 Places API Places Details: 2389 Counts $40.61

Nov 1 – 30, 2018 Places API Contact Data: 2385 Counts $7.17

Nov 1 – 30, 2018 Places API Atmosphere Data: 2385 Counts $11.95



来源:https://stackoverflow.com/questions/44176974/how-to-get-place-or-placeid-by-latlng-in-android-using-google-places-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!