ThinkGeo.com    |     Documentation    |     Premium Support

Wpf mapsuite PanZoomBar and custom zoom level goes out of zoom bound

Hi,

We have two problems with the Wpf MapSuite. We are using mapsuite 7.xxx. Our setup is the map suite has 30 Custom zoom levels

When we draw a feature, the Extent is computed and set for the map control. and then refreshed. Now there are two problems we are facing:

1. On Draw the ZoomBar is not updated accordingly when shown. See Image 1



2. ZoomBar area does not resize itself for higher then 20 ZoomLevels. Why and how to make him do that? ZoomBar goes out beyond the zoom scale when zoomed in with mouse wheel. But Does not allow to zoom in with Mouse!! See Image 2



We are looking forward to any help

002_Image_1.png (26.6 KB)
002_Image_2.png (28.2 KB)

Hi Syed,



Our latest version is 8.0 and I found the custom zoomlevel works well there, as below is my test about set 30 zoomlevels.



Please make sure your scale is correct and could you please try our latest version after you review your scale setting?


My test code:





            ZoomLevelSet set = new ZoomLevelSet();
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel01);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel02);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel03);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel04);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel05);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel06);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel07);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel08);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel09);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel10);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel11);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel12);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel13);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel14);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel15);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel16);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel17);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel18);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel19);
            set.CustomZoomLevels.Add(Map1.ZoomLevelSet.ZoomLevel20);
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 2));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 4));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 8));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 16));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 32));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 64));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 128));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 256));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 512));
            set.CustomZoomLevels.Add(new ZoomLevel(Map1.ZoomLevelSet.ZoomLevel20.Scale / 1024));



            Map1.ZoomLevelSet = set;




As below is how it looks:






Regards,



Don

Hi Don, 

Thank you for your reply!! Does this mean that the problem is still ther in Wpf map suite 7.xx? 

With the first problem, What do you mean if the scale is correct? My problem was When a Extent is set in code it does not reflect the zoom bar. Zoom bar is still at some wrong position. However If I rotate the mouse wheel a little bit then the bar moves to the right place!!



And for the second problem: zoom bar going out of bound, Following is the Zoom level set that we have and then we assign to the map suite new object of ExtendedZoomLevelSet



public class ExtendedZoomLevelSet : ZoomLevelSet
 {
        public ExtendedZoomLevelSet()
        {
            // Start from zoom scale 1
            double scale = this.ZoomLevel01.Scale;
            for (int i = 0; i < 30; i++)
            {
                this.CustomZoomLevels.Add(new ZoomLevel(scale));
                scale /= 2;
            }
        }
    }

And Upgrade to mapsuite 8.xx is also not the best option for us considering the price of the component!!

Looking forward for your reply!! Kind regards,

Murshed







Hi Murshed, 
  
 It looks you need modify Map1.MinimumScale after you append more 10 levels to ZoomLevelSet after 20. 
  
 Please try the code as below, I test it works well in 7.0.0.339: 
  
  
ZoomLevelSet set = new ZoomLevelSet();
            set = new ExtendedZoomLevelSet();

            Map1.ZoomLevelSet = set;
            Map1.MinimumScale = set.CustomZoomLevels[set.CustomZoomLevels.Count - 1].Scale;

 
  
 Please let me know whether that works for you. 
  
 Regards, 
  
 Don

Hi Don,

I checked the code with our project.

1. the zoom bar still goes out of the bound. 

2. The Zoom bar is initially at the minimum position even though it is zoomed in to some other level.



Our code looks like below, and FYI we set the zoom levels at a later point, means we create the control does some basic installation, every time user refresh, we set the zoom level set based on the requested layer type


public static void InitializeMapZoomLevel(WpfMap controlToPrepare, DtoRasterMapLayerBase decisionMakerLayer)
        {
            if (controlToPrepare == null || decisionMakerLayer == null)
            {
                return;
            }
 
            controlToPrepare.MapTools.PanZoomBar.ClipToBounds = true;
            ZoomLevelSet set;
            if (decisionMakerLayer is DtoGoogleMapLayer)
            {
                set = new CustomGoogleZoomLevelSet();
                controlToPrepare.ZoomLevelSet = set;
                controlToPrepare.MinimumScale = set.CustomZoomLevels[set.CustomZoomLevels.Count - 1].Scale;
                controlToPrepare.MapTools.PanZoomBar.UpdateLayout();
                return;
            }
 
            if (decisionMakerLayer is DtoBingMapLayer)
            {
                controlToPrepare.ZoomLevelSet = set = new CustomBingZoomLevelSet();
                controlToPrepare.MinimumScale = set.CustomZoomLevels[set.CustomZoomLevels.Count - 1].Scale;
                controlToPrepare.MapTools.PanZoomBar.UpdateLayout();
                return;
            }
 
            if (decisionMakerLayer is DtoOpenStreetMapLayer)
            {
                controlToPrepare.ZoomLevelSet = set = new CustomOpenStreetMapZoomSet();
                controlToPrepare.MinimumScale = set.CustomZoomLevels[set.CustomZoomLevels.Count - 1].Scale;
                controlToPrepare.MapTools.PanZoomBar.UpdateLayout();
                return;
            }
 
            if (decisionMakerLayer is DtoWmsLayer)
            {
                controlToPrepare.ZoomLevelSet = set = new ZoomLevelSet();
                controlToPrepare.MinimumScale = set.CustomZoomLevels[set.CustomZoomLevels.Count - 1].Scale;
                controlToPrepare.MapTools.PanZoomBar.UpdateLayout();
                return;
            }
 
            set = new ExtendedZoomLevelSet();
            controlToPrepare.ZoomLevelSet = set;
            controlToPrepare.MinimumScale = set.CustomZoomLevels[set.CustomZoomLevels.Count - 1].Scale;             
            controlToPrepare.MapTools.PanZoomBar.UpdateLayout();
        }

After this block the Layers are added to the map control and each layer will have diff elements- And after that we calculate the MapExtent and Finally refresh the WpfMap

Regards,

Murshed




Hi Murshed,  
  
 Thanks for let us know that.  
  
 Could you please create a standalone project which contains how you implement the panzoombar and reproduce this? 
  
 So we can easily reproduce this and quickly help you find a solution. 
  
 Regards, 
  
 Don

Hi, Murshed.

I wonder how can I use these codes. Do I need another image resizer to help defining the size of images? I am almost a green hand here. Any suggestion will be appreciated. Thanks in advance.







Best regards,

Arron

Hi Arron, 
  
 Have you met the same issue with Murshed? 
  
 Regards, 
  
 Don