Select to view content in your preferred language

How to use zoom slider?

1040
3
05-24-2018 03:52 AM
VijitWadhwa
Occasional Contributor

How can i zoom a map and come back to its default view using zoom slider ??

0 Kudos
3 Replies
VijitWadhwa
Occasional Contributor

The slider should co-ordinate with the mouse scroll zoom .. the mouse scroll zoom and the zoom through slider should be syncronized together . How can this be achieved ??

0 Kudos
dotMorten_esri
Esri Notable Contributor

I'd create a normal slider, set min/max between 1 and 20 and map the slider's values to scales. It 1 = zoomed all the way out, 2 == half that scale, etc. When the value changes, call the Zoom method on the view to you calculated scale (you could probably do something like MinScale / Math.Log(slider.Value) to get a reasonable behavior - MinScale would be the scale where you're zoomed all the way out).

You could then listen to the scale changed event on the view to update the slider back to keep them in sync.

You'll just have to write a little bit of code (like using a Boolean flag) to ensure these events don't go back and forth in an infinite loop (ie mouse wheel zoom causes slider to change. That automated change in the slider causes MapView to zoom, and the cycle continues...).

Silly devils-advocate question though: If you have a mouse-wheel and touch zoom why the need for a zoom slider? It's a paradigm most apps have moved away from.

0 Kudos
VijitWadhwa
Occasional Contributor

Hi,

Sorry sir , but this was the requirement of client for whom I am developing

0 Kudos