简体   繁体   English

Google Maps API Geocoder不会按placeId返回位置

[英]Google Maps API Geocoder doesn't return location by placeId

I use AutocompleteService.getPlacePredictions method to get autocomplete items for my drop down. 我使用AutocompleteService.getPlacePredictions方法为下拉菜单获取自动完成项。 Very often that method returns "long" placeIds that look like this (actual placeId): 该方法通常会返回如下所示的“长” placeId(实际的placeId):

ChIJx55rzdwQ9YgRHB-NARRWZyuaBjAxNzExIERvbm5hIEx5bm4gRHJpdmUsIFNteXJuYSwgR0EsIFVuaXRlZCBTdGF0ZXM ChIJx55rzdwQ9YgRHB-NARRWZyuaBjAxNzExiervbm5hIEx5bm4gRHJpdmUsIFNτXJuYSwgR0EsIFVuaXRlZCBTdGF0ZXM

If I then try to pass that place ID to Geocoder I get status of ZERO_RESULTS and no places: 然后,如果我尝试将该地点ID传递给Geocoder,则会得到ZERO_RESULTS的状态,但没有任何地点:

new google.maps.Geocoder().geocode(
  { placeId: "thatLongPlaceId"},
  function (results, status) { /* no place data returned */ });

But at the same time if I make the following GET call the same placeId returns the expected address: 但是同时,如果我进行以下GET调用,则相同的placeId返回期望的地址:

https://maps.googleapis.com/maps/api/place/details/json?key=MyApiKey&placeid=ChIJx55rzdwQ9YgRHB-NARRWZyuaBjAxNzExIERvbm5hIEx5bm4gRHJpdmUsIFNteXJuYSwgR0EsIFVuaXRlZCBTdGF0ZXM

What am I doing wrong? 我究竟做错了什么? What's the proper way of using that long place ID to get place data? 使用该长地点ID来获取地点数据的正确方法是什么?

I think the autocomplete endpoint is not returning valid placeids as of today or yesterday. 我认为截至今天或昨天,自动填充端点未返回有效的Placeid。 I'm running into a similar problem. 我遇到了类似的问题。

See Google Place Autocomplete API returning wrong place id 查看Google Place Autocomplete API返回错误的位置ID

The ZERO_RESULTS problem isn't because of the long place ids. ZERO_RESULTS问题不是由于长场所ID引起的。 To see this, try using the (long) place id from an autocomplete result for an address in Sydney, for eg 要查看此信息,请尝试使用自动完成结果中的(长)地点ID作为悉尼的地址,例如

ChIJr-__yjeuEmsR3RMEBNOoUn-aBjQ0OCBQaXJyYW1hIFJvYWQsIFB5cm1vbnQsIE5ldyBTb3V0aCBXYWxlcywgQXVzdHJhbGlh ChIJr -__ yjeuEmsR3RMEBNOoUn-aBjQ0OCBQaXJyYW1hIFJvYWQsIFB5cm1vbnQsIE5ldyBTb3V0aCBXYWxlcywgQXVzdHJhbGlh

The call to Geocoder.geocode should return 1 result. 对Geocoder.geocode的调用应返回1个结果。

Long story short, the Geocoding API (that google.maps.Geocoder uses) hasn't been fixed for the problem in https://code.google.com/p/gmaps-api-issues/issues/detail?id=11107 . 长话短说, https://code.google.com/p/gmaps-api-issues/issues/detail? id = 11107中的问题尚未修复Geocoding API(google.maps.Geocoder使用)。 。

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

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