Select to view content in your preferred language

How to disable/enable built-in navigation functions on JMap

3335
2
Jump to solution
03-26-2013 07:11 AM
JeremieJoalland1
Deactivated User
I need to develop customize navigation behavior for mouse click & drag and mouse wheel functions, so I don't want my JMap to have the built-in behavior like zoom in/out on scrolling mouse wheel.

ArcGIS documentation says "When you add a map (JMap) to your Java application, you can automatically pan and zoom the map using the mouse" (click and wheel)... but I don't want this.

How can I disable or enable the ArcGIS built-in mouse click & wheel functions ?
Please let me know if it is doable or not.

Thanks!
(I'm using ArcGIS for Java 10.1.1)
0 Kudos
1 Solution

Accepted Solutions
CarlosColón-Maldonado
Frequent Contributor
You have to override the built-in JMap's MapOverlay with an map overlay of your own, then DO NOT call the super mouse events on exit. Check the ArcGIS Runtime Java Samples 10.1.1 from Start Menu. This will provide you a lot of code sample for what you want to do (look at Toolkit -> Overlays -> Switch Overlays).

The com.esri.client.samples.toolkit.overlays.jar comes with some concrete map overlays that may or may not suit your needs, but they simply extend the com.esri.map.MapOverlay class and override its "onMouseXXXX(MouseEvent e)" methods.

View solution in original post

0 Kudos
2 Replies
CarlosColón-Maldonado
Frequent Contributor
You have to override the built-in JMap's MapOverlay with an map overlay of your own, then DO NOT call the super mouse events on exit. Check the ArcGIS Runtime Java Samples 10.1.1 from Start Menu. This will provide you a lot of code sample for what you want to do (look at Toolkit -> Overlays -> Switch Overlays).

The com.esri.client.samples.toolkit.overlays.jar comes with some concrete map overlays that may or may not suit your needs, but they simply extend the com.esri.map.MapOverlay class and override its "onMouseXXXX(MouseEvent e)" methods.
0 Kudos
JeremieJoalland1
Deactivated User
Great, it's working fine. quite simple
Thanks a lot !

my customize MapOverlay :

package ...;

import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

import com.esri.map.MapOverlay;

public class MyMapOverlay extends MapOverlay {

 /**
  * auto-generated Serial Version UID
  */
 private static final long serialVersionUID = 1L;

 @Override
    public void onMouseWheelMoved(MouseWheelEvent event) {
     // do nothing to block the built-in navigation by Mouse Wheel
    }
 
    @Override
    public void onMousePressed(MouseEvent event) {
     // do nothing to block the built-in navigation by Mouse Click & Drag
    }

    @Override
    public void onMouseDragged(MouseEvent event) {
     // do nothing to block the built-in navigation by Mouse Click & Drag
    }
}


and just need to add this Overlay to my map :

JMap jMap = new JMap();

// add the customize MapOverlay to block/manage built-in navigation functions
MyMapOverlay myMapOverlay = new MyMapOverlay();
jMap.addMapOverlay(myMapOverlay);
0 Kudos