简体   繁体   English

如何使用Google Places API在android中通过latLng获取位置信息或位置信息?

[英]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 ? 如何使用Google Places api在android中通过latLng获取地点或地名? I want to get place or placeid when i get latLng 当我得到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 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. 您将收到包含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 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. 是的,我们从Google获得了-200美元,但这全取决于您拥有多少用户以及您需要使用地理编码器的频率。 60k requests per month to the geocoder - easy $300 only for to use the geocoder : 每月向地址解析器发送6万个请求-仅需使用地址解析器即可轻松获得$ 300:

Nov 1 – 30, 2018 Geocoding API Geocoding: 6073 Counts - $30.38 2018年11月1日至30日,地理编码API地理编码:6073个计数-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 2018年11月1日至30日地方API地方详细信息:2389计数$ 40.61

Nov 1 – 30, 2018 Places API Contact Data: 2385 Counts $7.17 2018年11月1日至30日,Places API联系数据:2385计数$ 7.17

Nov 1 – 30, 2018 Places API Atmosphere Data: 2385 Counts $11.95 2018年11月1日至30日,Places API大气数据:2385计数$ 11.95

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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