Android Google 地图 v2 可点击标记标题
Android Google Maps v2 clickable marker title
我的应用程序中有一张 Google 地图。标记已经可以点击,但我正在寻找一种方法来使标题可点击以执行操作(比如转到地点 "description" 页面)。这就是我的意思
public class MapFragment extends Fragment {
private GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_map, container,
false);
String myTag = getTag();
((PlacesAndMapActivity) getActivity()).setTabFragmentMap(myTag);
map = ((SupportMapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
map.addMarker(new MarkerOptions().position(new LatLng(34.039407, -118.254763))
.title("Restaurant 1"));
return rootView;
}
}
我可以让标题可以点击吗?谢谢
您想使用GoogleMap.OnInfoWindowClickListener
Class 概述
标记信息 window.
上 click/tap 事件的回调接口
public abstract void onInfoWindowClick (Marker marker)
点击标记的信息 window 时调用。
我的应用程序中有一张 Google 地图。标记已经可以点击,但我正在寻找一种方法来使标题可点击以执行操作(比如转到地点 "description" 页面)。这就是我的意思
public class MapFragment extends Fragment {
private GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_map, container,
false);
String myTag = getTag();
((PlacesAndMapActivity) getActivity()).setTabFragmentMap(myTag);
map = ((SupportMapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
map.addMarker(new MarkerOptions().position(new LatLng(34.039407, -118.254763))
.title("Restaurant 1"));
return rootView;
}
}
我可以让标题可以点击吗?谢谢
您想使用GoogleMap.OnInfoWindowClickListener
Class 概述 标记信息 window.
上 click/tap 事件的回调接口public abstract void onInfoWindowClick (Marker marker)
点击标记的信息 window 时调用。