How to perform map marker click in HERE MAP (android )

前端 未结 3 1622
后悔当初
后悔当初 2021-01-21 09:14

I am using a map. I found an issue. How do i know which marker is clicked?

@Override
public boolean onMapObjectsSelected(List         


        
相关标签:
3条回答
  • 2021-01-21 09:27

    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.

    0 讨论(0)
  • 2021-01-21 09:34
      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);
    
    0 讨论(0)
  • 2021-01-21 09:35
    @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;
    }
    
    0 讨论(0)
提交回复
热议问题