Decide the zoom level of Mapview for a feature based on a layers min and max scale

613
0
05-05-2021 12:51 PM
by Anonymous User
Not applicable

Hello Friends,

In one of my project, I have a scenario where when my mapview zoom to a particular feature, one layer on my map become invisible as the MapView's scale value goes beyond that layers  min or max scale value. So my requirement is that the mapview should zoom to the required feature keeping the layer visible as well. I am using the below code to zoom to the feature:

mapview .goTo({ target: result.features });

can we restrict goTo method to zoom to this feature and also keep the mapview's scale/zoom value to stay between the layer's (layer which I doesn't want to become invisible when the mapview zoom to any feature) min and max scale value.

I tried listening to the mapview's stationary property and in this event I am checking the zoom value of the mapview after it has zoomed to the required feature and if that zoom value is greater than 13  then I set it to 13 and if it's less than 12 then I set it to 12. I am doing this because the layer is visible only at these zoom level (12 and 13). this works but the map's zooming transition is not smooth as sometimes map zoom to far in and then back's up or vice versa because we are setting the zoom level again in the mapview's stationary event

mapView.watch("stationary", (newValue) => {

if (mapView.zoom > 13) {

mapView.zoom = 13;
}
else if (mapView.zoom < 12) {

mapView.zoom = 12;
}

 

Any , Idea on how to achieve this is much appreciated. basically what I need is Mapview should zoom to a particular feature but the zoom level should be within the layer's visibility zoom level and should not go to a zoom level where the layer become invisible.

 

Thank,

Rauf

0 Kudos
0 Replies