I have used xml layout to make marker .In that layout there is five buttons 'A','B','C','D','E'. I follow this link.I want to show different toast message click on different button like if user click on button 'A' then message will be 'you have clicked on button A'. .How to do that? Please help. Thanks in advance.
How to handle click event component of custom marker in android
Asked Answered
Marker a,b;
GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
a= mMap.addMarker(new MarkerOptions()
.position(sc)
.title("A")
.snippet("A")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.a)));
b= mMap.addMarker(new MarkerOptions()
.position(lng)
.title("B")
.snippet("B")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.b)));
mMap.setOnMarkerClickListener(new OnMarkerClickListener()
{
@Override
public boolean onMarkerClick(Marker arg0) {
// if marker source is clicked
if(arg0.getTitle().equals("A")){
// display toast
Toast.makeText(MainActivity.this, arg0.getTitle(), Toast.LENGTH_SHORT).show();
}
// if marker source is clicked
else if(arg0.getTitle().equals("B")){
Toast.makeText(MainActivity.this, arg0.getTitle(), Toast.LENGTH_SHORT).show();
}
return true;
}
});
hello Shubham a and b not different marker , A,B,C,D, E are component of marker –
Twotone
© 2022 - 2024 — McMap. All rights reserved.