如何使用Android place API显示更具体的地方?

时间:2016-09-06 05:11:33

标签: java android android-studio google-places-api

我可以使用"类型"在地图上显示标记。使用places API的参数,但如何显示特定的标记?

例如;让我们说我使用" department _ stores"的特定类型参数显示标记,我将如何仅显示Walmarts?

places API文档列出了不同的"类型"可用,但没有解释如何根据名称显示特定地点。这甚至可能吗?

1 个答案:

答案 0 :(得分:0)

使用以下代码,您可以根据类型添加各种类型的标记图标

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;
    }
相关问题