Mouse Wheel Zooming disable

236
0
09-17-2019 03:41 AM
S_MMaruf
New Contributor II

Hi,

I am trying to disable mouse wheel zoom  at max zoom level 18 and min zoom level 3 . I created scroll event which disable zoombuttons  at max zoom level and min zoom level when I do zoomIn and zoomOut at those level by using mouse wheel zoom. i also use "mapView.setEnableMouseZoom(false)" . what am i missing , i dont understand . so can anyone help me to figure out what is the wrong? 

// zoomIn and zoomOut by using mouse wheel.
mapView.setOnScroll(new EventHandler<ScrollEvent>() {
public void handle(ScrollEvent se) {
// zoomIn by using mouse wheel and zooIn Button disable at zoom level at 18 while using mouse wheel zoomIn
zoomOut.setDisable(false);

map.zoomInFunction();
if (mapView.getMapScale() <= 2256.994353) {
zoomIn.setDisable(true);
mapView.setEnableMouseZoom(false);

}
// zoomOut by using mouse wheel and zoomOut Button disable at zoom level at 3 while using mouse wheel zoomOut
if (se.getDeltaY()<0) {
zoomIn.setDisable(false);
map.zoomOutFunction();
if (mapView.getMapScale() >= 7.3957190948944E7) {
zoomOut.setDisable(true);
mapView.setEnableMouseZoom(false);
}
}

public void zoomInFunction() {
Viewpoint current = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE);

Viewpoint zoomedIn = new Viewpoint((Point) current.getTargetGeometry(), current.getTargetScale() / 2.0);
mapView.setViewpointAsync(zoomedIn);
System.out.println(current.getTargetScale() / 2);

}

public void zoomOutFunction()
{
Viewpoint current = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE);

Viewpoint zoomedIn = new Viewpoint((Point) current.getTargetGeometry(), current.getTargetScale() * 2.0);
mapView.setViewpointAsync(zoomedIn);
System.out.println(current.getTargetScale() * 2);
}

0 Kudos
0 Replies