android - Android Google Places Api 评级为空
问题描述
我正在使用以下代码从当前用户那里获取特定的附近地点。虽然我得到了我想要的一切,但我无法获得评级。它总是返回 null。我究竟做错了什么?
private void ShowNearbyPlaces(List<HashMap<String, String>> nearbyPlacesList) {
for (int i = 0; i < nearbyPlacesList.size(); i++) {
Log.d("onPostExecute", "Entered into showing locations");
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> googlePlace = nearbyPlacesList.get(i);
double lat = Double.parseDouble(Objects.requireNonNull(googlePlace.get("lat")));
double lng = Double.parseDouble(Objects.requireNonNull(googlePlace.get("lng")));
String placeName = googlePlace.get("place_name");
String vicinity = googlePlace.get("vicinity");
String openNow = googlePlace.get("open_now");
String rating = googlePlace.get("rating");
Log.d("ShowNearbyPlaces", "GOOGLE PLACE :" + openNow);
String openFlag = googlePlace.get("openFlag");
String isOpen;
if (openNow == "true") {
isOpen = "open";
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
} else if (openNow == "false" && openFlag == "true") {
isOpen = "closed";
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
} else {
isOpen = "N/A";
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
}
if (rating != null){
if (rating.isEmpty()) {
rating = "N/A";
}
}
else
rating = "N/A";
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title("NAME: " + placeName + "\nSTREET: " + vicinity + "\nSTATUS: " + isOpen +"\nRATING: "+rating);
mMap.addMarker(markerOptions);
}
}
解决方案
推荐阅读
- amazon-web-services - aws - 调用 PutMetricData 操作时发生错误 (AccessDenied)
- gdb - 从终端运行 GDB 'commands' 命令?
- reactjs - 使用不在行中的材料表编辑其他字段
- python - Python循环:字符串索引超出范围
- r - 如何使函数跳过向量中的参数
- reactjs - 如何在工具提示悬停在点 Highcharts 上动态更改图表标题 .. React JS
- html - 变量链接在 TypeScript 中是如何工作的?
- python - 如何收集所有指定的href?
- ssh - 如何监视日志(Linux)文件并计算字符串出现的次数(如登录尝试失败)以将其添加到 InfluxDB?
- python - 如何在python中用两个不同的单词将两个名字拆分在一起