【发布时间】:2014-07-04 17:24:33
【问题描述】:
我正在尝试创建一个类似于 Waze 的应用,但我不知道如何为标记制作弹出菜单 喜欢this
我正在尝试做的系统是,如果用户决定标记他们当前的位置或双击地图上的任何位置,则会弹出一个菜单,其中包含我自己的标记选择。 我正在使用适用于 Android 和 iOS 的最新版 Google 地图
【问题讨论】:
标签: android ios google-maps-markers google-maps-android-api-2
我正在尝试创建一个类似于 Waze 的应用,但我不知道如何为标记制作弹出菜单 喜欢this
我正在尝试做的系统是,如果用户决定标记他们当前的位置或双击地图上的任何位置,则会弹出一个菜单,其中包含我自己的标记选择。 我正在使用适用于 Android 和 iOS 的最新版 Google 地图
【问题讨论】:
标签: android ios google-maps-markers google-maps-android-api-2
您可以使用Adapter自定义弹出窗口,只需调用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;
}
});
您可以阅读InfoWindowAdapter接口的文档。
【讨论】: