android 从谷歌Map获取燃油价格

bmvo0sr5  于 2024-01-04  发布在  Android
关注(0)|答案(2)|浏览(146)

我正在尝试检索附近所有加油站的燃油价格。我使用的是PlacesApi。虽然它检索了所有加油站的信息,如位置,地址,评级等,但它不返回燃油价格信息。经过一段时间的搜索,我发现MapAPI不返回燃油API。有没有任何方法可以获得此信息?
这就是我到目前为止所实施的。

  1. List<PlaceDetails> list = new ArrayList<>();
  2. GeocodingResult[] geocodingResults = new GeocodingResult[0];
  3. try {
  4. geocodingResults = GeocodingApi.geocode(context,"Dallas").await();
  5. if (geocodingResults.length > 0) {
  6. LatLng location = geocodingResults[0].geometry.location;
  7. // Perform the Places API request to get the gas stations in Dallas
  8. PlacesSearchResponse searchResponse = PlacesApi.nearbySearchQuery(context, location)
  9. .radius(20000) // Specify the search radius in meters (adjust as needed)
  10. .type(PlaceType.GAS_STATION) // Search for gas stations
  11. .await();
  12. // Iterate through the results and print the gas station names
  13. for (PlacesSearchResult result : searchResponse.results) {
  14. PlaceDetails placeDetails = PlacesApi.placeDetails(context, result.placeId).awaitIgnoreError();
  15. list.add(placeDetails);
  16. System.out.println(result.name);
  17. }
  18. } else {
  19. System.out.println("Unable to geocode Dallas.");
  20. }
  21. } catch (Exception e) {
  22. throw new RuntimeException(e);
  23. }

字符串
placeDetails对象包含除燃料信息之外的所有信息。


的数据

b1zrtrql

b1zrtrql1#

目前没有在Places API中添加Fuel Prices数据的计划

首先,谷歌Map(App)和谷歌Map(API)是不同的平台,所以我们应该设定我们的期望,他们有不同的特点和功能。
现在,关于在Places API中添加Fuel Prices数据,3年前(2020年7月)提交了一份与此相关的Feature Request,您可以在此链接中看到它:
https://issuetracker.google.com/issues/162155201
请注意,上面的Issue Tracker条目是有关上述问题的公共信息的权威来源,所有与公共相关的更新都发布在那里。
话虽如此,看起来Google目前还没有计划将此功能添加到Places API中,因为他们将其标记为 * Won 't Fix(不可行)* 并表示:
我们已经审核了您的请求,目前我们没有计划为Places API实现此功能。请注意,Places API旨在为不同的受支持place_types提供通用详细信息,而不仅仅是gas_stations
如果你仍然对这个特性感兴趣,你可以在我提供的链接中对特性请求投赞成票,并在那里评论你的用例以帮助重新考虑。
我希望这些信息有帮助!

fumotvh3

fumotvh32#

Google Places API(新)现在有燃油价格。https://developers.google.com/maps/documentation/places/web-service/reference/rest/v1/places#fuelprice

相关问题