我正在尝试检索附近所有加油站的燃油价格。我使用的是PlacesApi
。虽然它检索了所有加油站的信息,如位置,地址,评级等,但它不返回燃油价格信息。经过一段时间的搜索,我发现MapAPI不返回燃油API。有没有任何方法可以获得此信息?
这就是我到目前为止所实施的。
List<PlaceDetails> list = new ArrayList<>();
GeocodingResult[] geocodingResults = new GeocodingResult[0];
try {
geocodingResults = GeocodingApi.geocode(context,"Dallas").await();
if (geocodingResults.length > 0) {
LatLng location = geocodingResults[0].geometry.location;
// Perform the Places API request to get the gas stations in Dallas
PlacesSearchResponse searchResponse = PlacesApi.nearbySearchQuery(context, location)
.radius(20000) // Specify the search radius in meters (adjust as needed)
.type(PlaceType.GAS_STATION) // Search for gas stations
.await();
// Iterate through the results and print the gas station names
for (PlacesSearchResult result : searchResponse.results) {
PlaceDetails placeDetails = PlacesApi.placeDetails(context, result.placeId).awaitIgnoreError();
list.add(placeDetails);
System.out.println(result.name);
}
} else {
System.out.println("Unable to geocode Dallas.");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
字符串placeDetails
对象包含除燃料信息之外的所有信息。
的数据
2条答案
按热度按时间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
。如果你仍然对这个特性感兴趣,你可以在我提供的链接中对特性请求投赞成票,并在那里评论你的用例以帮助重新考虑。
我希望这些信息有帮助!
fumotvh32#
Google Places API(新)现在有燃油价格。https://developers.google.com/maps/documentation/places/web-service/reference/rest/v1/places#fuelprice