如何用 Android 个地方 API 显示更具体的地方?
How to show more specific places with Android places API?
我可以使用带有地点 API 的 "type" 参数在地图上显示标记,但如何显示特定标记?
例如;假设我使用 "department _ stores" 的特定类型参数显示标记,我将如何只显示沃尔玛?
地点 API 文档列出了不同的 "types" 可用但没有解释如何根据其名称显示特定地点。这可能吗?
使用下面的代码,您可以根据其类型添加各种类型的标记图标
MarkerrOoptions markerOptions = new MarkerOptions();
markerOptions.icon(BitmapDescriptorFactory.fromResource(getMarkerIcon(type)));
markerOptions.snippet(item.getSnippet());
markerOptions.title(item.getTitle());
map.addMarker(markerOptions);
/*获取标记的方法*/
private int getMarkerIcon(String type) {
int id = 0;
if(type == null) {
return R.drawable.ic_restaurant_map;
}
switch (type) {
case "cafe" :
id = R.drawable.ic_cafe_map;
break;
case "department _ stores" :
id = R.drawable.ic_department_store;
break;
case "restaurant" :
id = R.drawable.ic_restaurant_map;
break;
case "bar" :
id = R.drawable.ic_bar_map;
break;
}
return id;
}
我可以使用带有地点 API 的 "type" 参数在地图上显示标记,但如何显示特定标记?
例如;假设我使用 "department _ stores" 的特定类型参数显示标记,我将如何只显示沃尔玛?
地点 API 文档列出了不同的 "types" 可用但没有解释如何根据其名称显示特定地点。这可能吗?
使用下面的代码,您可以根据其类型添加各种类型的标记图标
MarkerrOoptions markerOptions = new MarkerOptions();
markerOptions.icon(BitmapDescriptorFactory.fromResource(getMarkerIcon(type)));
markerOptions.snippet(item.getSnippet());
markerOptions.title(item.getTitle());
map.addMarker(markerOptions);
/*获取标记的方法*/
private int getMarkerIcon(String type) {
int id = 0;
if(type == null) {
return R.drawable.ic_restaurant_map;
}
switch (type) {
case "cafe" :
id = R.drawable.ic_cafe_map;
break;
case "department _ stores" :
id = R.drawable.ic_department_store;
break;
case "restaurant" :
id = R.drawable.ic_restaurant_map;
break;
case "bar" :
id = R.drawable.ic_bar_map;
break;
}
return id;
}