ThinkGeo.com    |     Documentation    |     Premium Support

Zooing Level Mouse Wheel

Hi,


 


I have a shape file with land parcels which i am loading, however i cannot zoom to the level i need. I have alo noticed that the starting range is also very low i.e (the city can be zoomed out a lot which is not really requird).


 


The question is how can i zoom further? or shift the zooming levels so i can zoom further.


 


Regards,


 


Adrian



Can you give a little more explanation on what you mean by not being able to zoom to the level you need? Is it that it does not allow you to zoom in close enough? Then it might be that you have the Map Unit of your map not set correctly. For example, if your map is in Decimal Degrees and you have the MapUnit of the map set to Meters, it is not going to allow you zoom in correctly.

 When you say "the city can be zoomed out a lot which is not really required", I think that you mean that the city layer should not be displayed after you zoom out to a certain level. For this you need to set the ApplyZoomLevel correctly so that it does not apply all the way up to zoom level 20, but less than that.



<the further="" zoom="" can="" i="" so="" levels="" zooming="" the="" shift="" or="" how="" is="" question=""></the>
"The question is how can i zoom further? or shift the zooming levels so i can zoom further"

Can you elaborate a little bit on that question. I am not sure I understand it.


Also, I would recommend you check out some projects in the Code Community related to zoom levels and other zoom related issues. I think it will help you get a better grasp on that concepts.


code.thinkgeo.com/projects/show/124


code.thinkgeo.com/projects/show/111


code.thinkgeo.com/projects/show/128


code.thinkgeo.com/projects/show/49


 



Adrian, I had the same problem.    There are 20 preset zoom levels defined by default.   These levels start much too far “zoomed out” for an application that looks at individual parcels in a land management system.   And I assume that as you are building a system for local use, you have no need to zoom out further than the city. 
  
 For our application (looking at ressearch test plots), we redefined the zoom levels with our own, and made them all be much lower values than the default values.   The lazy way to do it is to set a scale at something like 800000, and then iterate through to create 20 custom zoom levels, each dividing the previous scale by 1.25 or some factor that gives you nice steps as you zoom in and out.   We actually are doing 40 levels, but that is likely not necessary in your case: 
  
                 double scale = 160000000; 
                 for (int i = 0; i < 50; i++) 
                 { 
                     wfmMap.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(scale)); 
                     scale = scale / 1.25; 
                 } 
  
  
 Also, there is a property on the map called the MinimumScale.   You may need to set that, too. 
  
 And, as Val suggested, you’ll need to set your GeographyUnit to meters if you have projected data (or are projecting it), and I would assume that is the case in your application. 


Thank you Ted for your colaboration.


Adrian, you can find the project Zoom Levels Partitioning to see a complete project on how to get a more granular control on the zoom levels. code.thinkgeo.com/projects/show/zoomlevels


 



i have created the custom zoom levels following the examples provided.  
  
 what i am still missing is how to use the custom levels with the mouse wheel since this is still linked to the predefined zoom levels. 
  
 Also is there a way that i can change the valuse od the predefined zoom levels. I need to be able to zoom closer. 


In my app, as soon as I set the custom zoom levels so that I had low scales available, and set the MinimumScale so that I could get down to that level, everything "just worked".  Each click of the zoom wheel effectively took me up or down one level in scale.   Not sure if that was by accident or not, but it got the behavior I wanted.

Adrian, 
  
   Can you create a simple test sample where you set the zoom levels and it doesn’t work?  Send that to us as when we create it here it works fine.  I think maybe there is some small detail that is preventing it from working but we cannot see your exact code to find out why.  A small sample would isolate the issue and maybe if that works on your send you can see why you code doesn’t work.  Of course it could always be a bug on our and in that case your sample would really help us fix it quickly. 
  
 David

Hi,


 


I have attached the sample code that i am curently working on.


 


Would it help if i attahed the actual shapefiles as well?


 


Thanks and Regards,


Adrian


 



002_001_TestForm.zip (2.6 KB)

Yes, it would help to attach the actual shapefiles as well, if they are not too big. Otherwise with some slight modifications to your code, we should be able to have it run. Let us know if you are going to send us the shapefiles or not. Thank you.

I attached on of the 2 files used because the other was too large.


 


hope this helps.


 


as you may also notice when loading the shape file, I cannot add the map extent correctly because my values are in meters and the values i am inputting are generating an ArgumentOutOfRangeException Error


//winformsMap1.CurrentExtent = new RectangleShape(26544.00, 60605.00, 61818.00,93531.00);


 


Thanks once again for our support.


 


Regards


Adrian


 


 



CoastlineRegion.zip (363 KB)

For being able to zoom in closer, you need to set your custom zoom levels so that you have large scale for the last zoom level such as 1:250 and you will see how close you can zoom in. Look at the code below. I have 11 zoom levels and with the Scale Bar you will see how close I can zoom in. Also notice, that at each Mouse Wheel change, you step one zoom level at a time which is the expected behavior.



winformsMap1.MapUnit = GeographyUnit.Meter;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            ScaleBarAdornmentLayer scaleBar = new ScaleBarAdornmentLayer();
            scaleBar.UnitFamily = UnitSystem.Metric;
            scaleBar.Location = AdornmentLocation.LowerLeft;

            winformsMap1.AdornmentOverlay.Layers.Add(scaleBar);

            string pathCoastLine = @"C:\ThinkGeo\Support\Posts\7643\DraggingIcon\data\Coastline_region.shp";
            
            ShapeFileFeatureLayer coastLineLayer = new ShapeFileFeatureLayer(pathCoastLine);
            coastLineLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Park1;
            coastLineLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ZoomLevelSet partitionedZoomLevelSet = new ZoomLevelSet();
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(500000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(200000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(100000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(50000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(25000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(10000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(5000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(2500));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(1000));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(500));
            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(250));
            winformsMap1.ZoomLevelSet = partitionedZoomLevelSet;

            LayerOverlay layerOverlay1 = new LayerOverlay();
            layerOverlay1.Layers.Add(coastLineLayer);
            winformsMap1.Overlays.Add(layerOverlay1);
          
            coastLineLayer.Open();
            winformsMap1.CurrentExtent = coastLineLayer.GetBoundingBox();
            coastLineLayer.Close();

            winformsMap1.Refresh();