从地址商家信息自动填充API来获取GPS坐标输入坐标、商家、地址、信息

2023-09-06 02:44:16 作者:獨行蒗子會擁風

我有,用户需要输入所需的地址在我的应用程序的地址字段。我已经使用谷歌地球codeR获得地址的GPS坐标。但现在我想使它更容易为用户使用商家信息自动填充。但商家信息自动填充只返回地方的地址,身份证和参考。

有没有一种方法来获得地址的使用商家信息自动填充API用户选择的GPS坐标?我一定要使用地理codeR之后用户再次从商家信息自动填充选择他的地址吗?

或者我应该使用API​​的地方后,再次在用户选择自己的地址,以获得地址的GPS坐标?我不想送,因为到位的使用限制多个请求到位置API。 。这是从商家的API ..There预期的响应是响应没有GPS坐标。

 状态:OK,
  predictions:[{
    说明:法国巴黎,
    ID:691b​​237b0322f28988f3ce03e321ff72a12167fd
    参考:CiQYAAAA0Q_JA ...... kT3ufVLDDvTQsOwZ_tc
    条款:[{
      值:巴黎,
      抵消:0
    },{
      值:法国,
      抵消:7
    }],
    类型:GEO code],
    matched_substrings:[{
      偏移量:0,
      长度:5
    }]
  },{
    说明:巴黎,德克萨斯州,美国
    ID:518e47f3d7f39277eb3bc895cb84419c2b43b5ac
    参考:CjQjAAAAHnbxZZ ...... BDR3iIOFdMTxwo1jHg
    条款:[{
      值:巴黎,
      抵消:0
    },{
      值:TX,
      抵消:7
    },{
      值:美的,
      抵消:11
    }],
    类型:GEO code],
    matched_substrings:[{
      偏移量:0,
      长度:5
    }]
  },{
    描述:巴黎,安大略省,加拿大,
    ID:e7ac9c89d4a590305242b0cb5bf43064027223c9
    参考:CjQhAAAAIv_YWYt ...... F8KZHY36TwMrbyu_g
    条款:[{
      值:巴黎,
      抵消:0
    },{
      值:安大略,
      抵消:7
    },{
      值:加拿大
      抵消:16
    }],
    类型:GEO code],
    matched_substrings:[{
      偏移量:0,
      长度:5
    }]
  }

解决方案

您只需使用地方详情的一部分的地方API,你得到使用参考的价值在每一个建议,参考实际到位。例如:

https://maps.googleapis.com/maps/api/place/details/json?reference=CiQYAAAA0Q_JA...kT3ufVLDDvTQsOwZ_tc&sensor=true&key=AddYourOwnKeyHere Android实战开发之 GPS定位实例

这将要给大家介绍的,包括它的坐标(点特定的位置,界限的区域)的位置信息。

I have an address field in my app where the user needs to enter the required address. I have used google Geocoder to get the GPS coordinates of the address . But now I want to make it easier for the user by using Places Autocomplete . But Places Autocomplete only returns the address , Id and reference of the place .

Is there a way to get the GPS coordinates of the address selected by the user using Places Autocomplete API ? Do I have to use Geocoder again after the user selects his address from Places Autocomplete ?

Or Should I use Places API again after the user selects his address to get the GPS coordinates of the address ? I dont want to send multiple requests to the Places API because of the usage limits in place . . This is the expected response from Places API ..There is no GPS coordinates in the response .

"status": "OK",
  "predictions": [ {
    "description": "Paris, France",
    "id" : "691b237b0322f28988f3ce03e321ff72a12167fd",
    "reference": "CiQYAAAA0Q_JA...kT3ufVLDDvTQsOwZ_tc",
    "terms": [ {
      "value": "Paris",
      "offset": 0
    }, {
      "value": "France",
      "offset": 7
    } ],
    "types": [ "geocode" ],
    "matched_substrings": [ {
      "offset": 0,
      "length": 5
    } ]
  }, {
    "description": "Paris, TX, United States",
    "id" : "518e47f3d7f39277eb3bc895cb84419c2b43b5ac",
    "reference": "CjQjAAAAHnbxZZ...BDR3iIOFdMTxwo1jHg",
    "terms": [ {
      "value": "Paris",
      "offset": 0
    }, {
      "value": "TX",
      "offset": 7
    }, {
      "value": "United States",
      "offset": 11
    } ],
    "types": [ "geocode" ],
    "matched_substrings": [ {
      "offset": 0,
      "length": 5
    } ]
  }, {
    "description": "Paris, Ontario, Canada",
    "id" : "e7ac9c89d4a590305242b0cb5bf43064027223c9",
    "reference": "CjQhAAAAIv_YWYt...F8KZHY36TwMrbyu_g",
    "terms": [ {
      "value": "Paris",
      "offset": 0
    }, {
      "value": "Ontario",
      "offset": 7
    }, {
      "value": "Canada",
      "offset": 16
    } ],
    "types": [ "geocode" ],
    "matched_substrings": [ {
      "offset": 0,
      "length": 5
    } ]
  }

解决方案

You simply use the Place Details part of the Places API where you get the actual place from the reference in each suggestion using the "reference" value. For example:

https://maps.googleapis.com/maps/api/place/details/json?reference=CiQYAAAA0Q_JA...kT3ufVLDDvTQsOwZ_tc&sensor=true&key=AddYourOwnKeyHere

This will give you information about the place including its coordinates (point for a specific location, bounds for an area).