I am trying to add a mouse listener to a MapMarker, so that when a mouse will hover a MapMarker, I could react with an event.
I implemented the mouseListener, but I can't really add a listener. The issue is that I did not find a way the MapMarker will addMouseListener, due to the fact that non of the hierarchy implements JPanel.
Any help appreciated
As noted here, the default
JMapViewer
constructor uses aDefaultMapController
, "which implements map moving by pressing the right mouse button and zooming by double click or by mouse wheel." To see map coordinates, extendDefaultMapController
, overridemouseClicked()
and use one of the viewer'sgetPosition()
methods. You can use your controller as shown in comments at line 65 ofDemo.java
, r30377.