Search code examples
google-mapsjxmaps

Marker mouseover state in JxMaps


Is there a way to add mouseover state to a marker in Google Maps embedded in Java app via JxMaps? I was looking for a way to show whether the marker is clickable or not on hover. However, I didn’t find a suitable method that sets this icon the API


Solution

  • To implement functionality like this, you have to attach to marker mouse events and change marker icon (using Marker.setIcon method) depending on mouse position.

    marker.addEventListener("mouseover", new MapEvent() {
       @Override
       public void onEvent() {
          marker.setIcon(hoverIcon);
       }
    }});
    
    marker.addEventListener("mouseout", new MapEvent() {
       @Override
       public void onEvent() {
          marker.setIcon(normalIcon);
       }
    }});