How can I know the actual zoom level my extent has?
Regards,
Carlos.
How can I know the actual zoom level my extent has?
Regards,
Carlos.
We have a Code Community sample that shows exactely that, please refer to GetZoomLevel project to see how to accomplish this: wiki.thinkgeo.com/wiki/Map_Suite_Wp...ng_Samples
Hi Val,
I know, it is where I come from, but it’s for Desktop edition, it calls winformsMap1.ZoomLevelSet.GetZoomLevel, where ZoomLevelSet is not present in WPF class.
Carlos.
Ok, I will get a guy from the Wpf team to answer that one. Thank you to point that out and we will see what the solution is for Wpf.
Hi Carlos,
There is a sample that shows you how to accomplish this in the “How Do I Sample” (which is available in both Evaluation and Full edition of the installer), it’s in the “Map Tools” tree node, labeled as “Add a pan zoom bar”.
Please check the sample out, and let us know if you have further questions.
Regards,
Tsui
Hi Carlos,
We are not sure if you want to know current zoom level by visual, or by code. Thanks to Tsui for his option that is for visual. While on another hand, we also support an API for getting zoom level index by code. Please try the overload method "GetSnappedZoomLevelIndex" on the WpfMap class; you can both use current scale or current extent as parameter for this method. It returns the zoom level index as you want.
Please give it a try and let us know if you have more queries.
Thanks,
Howard
Dear Howard,
Thanks a lot, It’s what I was looking for, to know it by code. I’m showing the zoom level so I can use it to adjust from which zoom level the features are shown.
Now I have the next problem… I also tried to set custom zoom levels, with the following code:
WpfMap1.ZoomLevelScales.Clear()
WpfMap1.ZoomLevelScales.Add(73000000)
WpfMap1.ZoomLevelScales.Add(50000000)
WpfMap1.ZoomLevelScales.Add(25000000)
WpfMap1.ZoomLevelScales.Add(10000000)
WpfMap1.ZoomLevelScales.Add(7000000)
WpfMap1.ZoomLevelScales.Add(5000000)
WpfMap1.ZoomLevelScales.Add(3000000)
WpfMap1.ZoomLevelScales.Add(2500000)
WpfMap1.ZoomLevelScales.Add(1000000)
WpfMap1.ZoomLevelScales.Add(500000)
WpfMap1.ZoomLevelScales.Add(250000)
WpfMap1.ZoomLevelScales.Add(100000)
WpfMap1.ZoomLevelScales.Add(60000)
WpfMap1.ZoomLevelScales.Add(30000)
WpfMap1.ZoomLevelScales.Add(10000)
It works fine for the first 3 zoom levels (despite it starts in zoom level 0 instead of 1), but I’m not able to zoom in beyond 25000000 scale when use this code. If I comment it it zoom normally.
Regards,
Carlos.
Hi Carlos,
There is a value that controls how much to zoom in/out every time the mouse wheel event happens. You can access this value through WpfMap.ExtentOverlay.ZoomPercentage.
The default value of ZoomPercentage is 50. So when the map zooms in from a scale of 73000000, we’ll calculate that the target scale should be 36500000 (which is 7300000*(100- ZoomPercentage)%).
And 36500000 is less than the next custom scale which is 50000000, so it passes the examination and zooms in successfully.
But when the map zooms in from a scale of 25000000, its target scale is going to be 12500000, and it’s greater than the next custom scale which is 10000000, so it fails the examination and does not zoom in.
In order to make it work, you can try to modify the custom scales like this:
73000000,50000000,26000000,14000000,8000000,5000000,3000000,2500000,1300000,660000,340000,180000,100000,60000,40000; and keep the default value of ZoomPercentage.
Or you can try to change the ZoomPercentage to be a greater value like 70.
In a nutshell, we need to keep the custom defined zoom scales compatible with the ZoomPercentage.
Hope this will help and please let us know if you have any other questions.
Regards,
Tsui
It worked.
Thanks.
Carlos.
Cool, let us know if you have any other questions.
Regards,
Tsui