ThinkGeo.com    |     Documentation    |     Premium Support

CuztomZoomLevels and ApplyStyleUntil

Hello,


I am interested to know if there has been a fix regarding use of the CustomZoomLevel collection involving more than 20 levels and then applying certain styles from any of the new ranges.


For example, if I have 100 ZoomLevels but would like to apply a style from CustomZoomLevel(30) to CustomZoomLevel(80) I do not believe there is a means to do this. We want to take maximum advantage of the TileCache without restricting a user to 20 ZoomLevels.


Thanks,


Nelson



Nelson, 
  
 Did this issue some up under another post somewhere?  I was wondering becasue you used the term fix as if we had that in the works.  I am just curious.  From what I understand off the cuff the ApplyUntil was designed to work for the simple zoom level case where you used the re-defined zoom levels.  Once you used the custom set you take responsibility as it is custom.   
  
   I can see from your scenario that you would be looking to a shortcut to apply styles across a bunch of zoom levels.  I am not sure if us expanding the API will help as it will be just for your scenario and in the custom zoom levels they are not intrinsically numbered except for the order they are in the collection.  I would be afraid that additional APIs would confuse the common case.  Having said all of that I will look to see how we can create something using our exisiting framework to try and give you waht you want through just extending our stuff and not modifying the core API. 
  
 David

Nelson,



  I have an idea.  What we can do is to change the zoom level set the Desktop Edition snaps to but do not change the 20 zoom levels you use to define your styles.  The method I am including will take a zoom level set and it will add even level steps in between the zooms levels you pass in.  This way the more granular zoom levels will match up with the reference set at certain points so your styles will match up but you will have more intermediate zoom levels.  Just make sure in the form load you set your reference zoom level set for snapping.  I included that one line of code as well.



David




// This is what you would call in the form load to set the 
// desktop edition to snap to these new and more granular zoom levels
winformsMap1.ZoomLevelSet = PartitionZoomLevelSet(2, new ZoomLevelSet());


        // This code will take the zoom level set you pass in and add
        // the number of intermetidate levels you specify.  
        public ZoomLevelSet PartitionZoomLevelSet(int stepsBetweenZoomLevels, ZoomLevelSet referenceZoomLevelSet)
        {
            ZoomLevelSet partitionedZoomLevelSet = new ZoomLevelSet();            
            Collection<ZoomLevel> zoomLevels = referenceZoomLevelSet.GetZoomLevels();

            partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(zoomLevels[0].Scale));
            foreach(ZoomLevel zoomLevel in zoomLevels)
            {
                System.Diagnostics.Debug.WriteLine("Reference Scale " + zoomLevel.Scale);
                double lowerScale = ZoomLevelSet.GetLowerZoomLevelScale(zoomLevel.Scale, referenceZoomLevelSet);
                if (lowerScale != zoomLevel.Scale)
                {
                    for (int x = 1; x < stepsBetweenZoomLevels + 2; x++)
                    {
                        double steppedScale = zoomLevel.Scale - (((zoomLevel.Scale - lowerScale) / (stepsBetweenZoomLevels + 1)) * x);
                        System.Diagnostics.Debug.WriteLine(steppedScale);
                        partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(steppedScale));
                    }
                }            
            }

            return partitionedZoomLevelSet;
        }
 


 



Hey David, 



At first glance this stuff looks cool and I'll be checking it out in a project relatively soon. Also, I couldn't find my exact post where I brought up the ApplyUntilZoomLevel issue although I remember having raised it myself. 



However I did find a post someone else made regarding the issue where I had chimed in on the feedback I had recieved on the matter. It was several months ago and was never brought up as a major issue anyways so it was relatively low priority anyways as far as I was concerned at the time. 

 


Edit: The above mentioned post was: gis.thinkgeo.com/Support/Dis...fault.aspx




When I have a moment I'll try this out but it seems like it would be a nice match. 



Thanks!



Nelson, 
  
  Great, I look forward to someone trying it out.  I am pretty sure soon it will go up in the code.thinkgeo.com community site.  I think it could be useful for people wanting the tiling but also needing just a bit more granularity in the snapping.   Anyway let me know how things go in the future. 
  
 David