GoogleMap mMap
Marker marker = mMap.addMarker(
new MarkerOptions()
.position(new LatLng(dLat, dLong))
.title("Your title")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)));
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker m) {
}
}
答案 0 :(得分:1)
像这样添加标记时,可以为每个标记添加标记
marker1 = mMap.addMarker(new MarkerOptions()
.position(yourPosition)
.title("yourTitle");
marker1.setTag("YourTag");
然后您可以通过访问来识别单击哪个标记 标记值
OnMarkerClickListener
。
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker m) {
if(m.getTag()=="YourTag"){
//Perfom your operation here
}else if(m.getTag()=="AnotherTag"){
//Perfom your operation here
}
}