AnsweredAssumed Answered

Handling Zooming function using Direct ScaleValue of Zoomlevel

Question asked by fusionsystems@maruf on Sep 24, 2019
Latest reply on Sep 24, 2019 by mbaird-esristaff

Hi,

I want  to develop zoom function (ZoomIn and ZoomOut)  by using ScaleValue of those ZoomLevel. At first , I stored those scalevalue of zoomlevels  in a array and I also create two button action (eg. ZoomIn and ZoomOut ) and   for ZoomIn fuction , i increase index number of array and for zoomOut function decrease index number of array to get map into desire zoom level. but in my map application , MapView is not zoomIn or Zoomout  ,  I use map.setReferenceScale() property but is not working , so my question is "is there any other property in which i use scaleValue of zoom levels for execute zoom function in in arcgis runtime sdk in Java ".  i have done some code for my application.

 

double [] ZoomScaleValueArr = {5.91657527591555E8,2.95828763795777E8,1.47914381897889E8,7.3957190948944E7,3.6978595474472E7,1.8489297737236E7,
9244648.868618,4622324.434309,2311162.217155,1155581.108577,577790.554289, 288895.277144,144447.638572, 72223.819286,36111.909643,
18055.954822,9027.977411,4513.988705,2256.994353,1128.497176,564.248588 };

 

public void setZoom(int zoom) {
if(minZoom <= zoom && zoom <= maxZoom)
{

double destScale = ZoomScaleValueArr[zoom];
//map do zooming to destinationScale
map.setReferenceScale(destScale);
Point centerPoint = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE).getTargetGeometry().getExtent().getCenter();
double currentReferenceScale = mapView.getMap().getReferenceScale();
Viewpoint newViewPoint = new Viewpoint(centerPoint, currentReferenceScale);
mapView.setViewpoint(newViewPoint);
System.out.println(currentReferenceScale);
System.out.println(centerPoint);
}

}

 

 

//zoomIn Function

zoomInBtn.setOnAction(actionEvent -> {
zoomOutBtn.setDisable(false);
zoomValue++;
map.setZoom(zoomValue);
if (zoomValue >= 15) {
zoomInBtn.setDisable(true);

}

});
//zoomOut Function
zoomOutBtn.setOnAction(actionEvent -> {
zoomInBtn.setDisable(false);
zoomValue--;
map.setZoom(zoomValue);

if (zoomValue <= 5) {

zoomOutBtn.setDisable(true);

}
});

Outcomes