简体   繁体   English

在Google Maps API V2中创建自定义标记菜单

[英]Creating a custom marker menu in google maps api V2

I'm trying to create an app similar to Waze but I don't know how to make a pop up menu for markers like this 我正在尝试创建类似于Waze的应用,但我不知道如何为此类标记创建弹出菜单

The system I'm trying do is that if a user decides to mark their current location or double tap anywhere on the map a menu will pop up with a selection of my own markers. 我正在尝试的系统是,如果用户决定标记他们的当前位置或在地图上的任意位置双击,将弹出带有我自己的标记选择的菜单。 I'm using the latest version of Google Maps for Android and iOS 我正在使用Android和iOS的最新版Google Maps

You can customize the pop up with an Adapter, just call the setInfoWindowAdapter method and override the following methods, like this: 您可以使用适配器自定义弹出窗口,只需调用setInfoWindowAdapter方法并覆盖以下方法,如下所示:

mGoogleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
            @Override
            public View getInfoWindow(Marker arg0) {
                return null;
            }

            @Override
            public View getInfoContents(Marker marker) {
                LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View rowView = inflater.inflate(R.layout.item_marker_location, null);
                TextView tvTitle   = (TextView) rowView.findViewById(R.id.tvMarkerTitle);
                TextView tvSnippet = (TextView) rowView.findViewById(R.id.tvMarkerSnippet);
                tvTitle.setText(marker.getTitle());
                tvSnippet.setText(marker.getSnippet());
                return rowView;
            }
        });

You can read the documentation of the InfoWindowAdapter interface. 您可以阅读InfoWindowAdapter接口的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM