[英]How to show more specific places with Android places API?
我可以使用帶有地方信息API的“類型”參數在地圖上顯示標記,但是如何顯示特定標記?
例如; 假設我使用“部門_商店”的特定類型參數顯示標記,那么如何只顯示沃爾瑪呢?
地方API文檔列出了可用的不同“類型”,但沒有說明如何根據其名稱顯示特定的地方。 那有可能嗎?
使用以下代碼,您可以根據其類型添加各種類型的標記圖標
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.