Search code examples
androidmapsontouchlistenerclickablemylocationoverlay

Clickable MyLocationOverlay


Is it possible to make the MyLocationOverlay marker clickable? I have to launch a spinner when the overlay marker is clicked.

myLocationOverlay.setTouchEventListener(new OverlayTouchEventListener() {

        @Override
        public void onTouch(MotionEvent arg0, MapView arg1) {
            showLocationOverlayDialog();
            Log.i("MainMapActivity", "Main.getView() — location touched");
        }
    });

This is what I have so far. I haven't started with the spinner yet. But with this code, I think it's not working. It does not enter the setTouchEventListener. Could anybody please help me?


Solution

  • Create subclass of MyLocationOverlay and override dispatchTap(). Than just create myLocationOverlay as instance of this class