简体   繁体   中英

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

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

您可以使用此Google Maps API

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM