I am using a map. I found an issue. How do i know which marker is clicked?
@Override
public boolean onMapObjectsSelected(List
To obtain which marker is clicked do like below in onMapObjectsSelected
method.
for (ViewObject viewObject : list) {
if (viewObject.getBaseType() == ViewObject.Type.USER_OBJECT) {
MapObject mapObject = (MapObject) viewObject;
if (mapObject.getType() == MapObject.Type.MARKER) {
MapMarker window_marker = ((MapMarker) mapObject);
System.out.println("Title is................."+window_marker.getTitle());
return false;
}
}
}
You have to find out which object type is selected in loop as above.
MapGesture.OnGestureListener onGestureListenernew= new
MapGesture.OnGestureListener() {
@Override
public void onPanStart() {
}
@Override
public void onPanEnd() {
}
@Override
public void onMultiFingerManipulationStart() {
}
@Override
public void onMultiFingerManipulationEnd() {
}
@Override
public boolean onMapObjectsSelected(List<ViewObject> list) {
for (ViewObject viewObject : list) {
if (viewObject.getBaseType() == ViewObject.Type.USER_OBJECT) {
MapObject mapObject = (MapObject) viewObject;
if (mapObject.getType() == MapObject.Type.MARKER) {
MapMarker window_marker = ((MapMarker)mapObject);
Log.d("danish","danish");
System.out.println("Title is................."+window_marker.getInfoBubbleHashCode());
Toast.makeText(m_activity,"Hello"+window_marker.getCoordinate(),Toast.LENGTH_LONG).show();
return false;
}
}
}
return false;
}
@Override
public boolean onTapEvent(PointF pointF) {
return false;
}
@Override
public boolean onDoubleTapEvent(PointF pointF) {
return false;
}
@Override
public void onPinchLocked() {
}
@Override
public boolean onPinchZoomEvent(float v, PointF pointF) {
return false;
}
@Override
public void onRotateLocked() {
}
@Override
public boolean onRotateEvent(float v) {
return false;
}
@Override
public boolean onTiltEvent(float v) {
return false;
}
@Override
public boolean onLongPressEvent(PointF pointF) {
return false;
}
@Override
public void onLongPressRelease() {
}
@Override
public boolean onTwoFingerTapEvent(PointF pointF) {
return false;
}
};
then add
m_mapFragment.getMapGesture().addOnGestureListener(onGestureListenernew);
@Override
public boolean onMapObjectsSelected(List<ViewObject> list) {
for (ViewObject viewObject : list) {
if (viewObject.getBaseType() == ViewObject.Type.USER_OBJECT) {
MapObject mapObject = (MapObject) viewObject;
if (mapObject.getType() == MapObject.Type.MARKER) {
MapMarker window_marker = ((MapMarker)mapObject);
Log.d("Title->",window_marker.getTitle());
Log.d("description->",window_marker.getDescription());
return true;
}
}
}
return false;
}