ThinkGeo.com    |     Documentation    |     Premium Support

Problem using ZoomLevelSet and default ZoomLevels (i.e. 01-20)

I'm trying to implement logic similar to what I was doing in the MapSuite 2.0 version (and was heavily shown in the 2.0 examples) using the default zoom levels. Previously I only had to set my MapUnit on the map and the default ZoomLevels 1-18 would magically work.  Now in version 3.0, i'm using the levels defined in the given Layer's ZoomLevelSet but I can't get it working.  I also tried something similar in the sample programs with no luck.  Hopefully i'm just missing something stupid but heres a real simple example of what i'm trying to do:




ShapeFileFeatureLayer layer3 = new ShapeFileFeatureLayer( @"...streets.shp" );


layer3.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level02;

layer3.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1;


layer3.ZoomLevelSet.ZoomLevel02.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level02;

layer3.ZoomLevelSet.ZoomLevel02.DefaultLineStyle = LineStyles.LocalRoad2;


layer3.ZoomLevelSet.ZoomLevel03.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level03;

layer3.ZoomLevelSet.ZoomLevel03.DefaultLineStyle = LineStyles.LocalRoad3;


layer3.ZoomLevelSet.ZoomLevel04.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

layer3.ZoomLevelSet.ZoomLevel04.DefaultLineStyle = LineStyles.LocalRoad4;

 


Thanks,


Chad



Chad, 
  
  Everything looks good that I can see.  Could you include all the code possibly?  I want to make sure you are setting the map unit and we need to also make sure the data is in the map unit you want.  Also one other thing is that you need to set the current extent.  This might be the problem.  You can open the layer and call the GetBoundingBox and close it.  Set the bounding box as the current extent.  Also make sure that you have added your layer to the StaticOverlay of the map.  If you send the complete code then I can get a better idea. 
  
 One other thing.  if you use a zoom level for jsut that level then you don’t need to set the ApplyUntilZoomLevel.  You can remove this for the first few levels and form your sample you only need it for the one that spans to ZoomLevel20. 
  
 David

The exact code pruned down to it's simplest state is below, i'm pretty confident the MapUnit is right (i tried all the others just incase) but this is same unit and same file that in MapSuite v2.0 works perfectly, now it doesnt work at all.  It's too bad your new samples for v3.0 dont show more samples using the kinds of features that v2.0 samples had.  If I recall correctly, that one has streets, labels, all kinds of stuff like that.


        Map.MapUnit = GeographyUnit.Meter;



         ShapeFileFeatureLayer layer3 = new ShapeFileFeatureLayer( @"J:\common\GISData\Delta GIS\BSA\streets.shp" );

         layer3.RequireIndex = false;


         layer3.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1;

         layer3.ZoomLevelSet.ZoomLevel02.DefaultLineStyle = LineStyles.LocalRoad2;

         layer3.ZoomLevelSet.ZoomLevel03.DefaultLineStyle = LineStyles.LocalRoad3;


         layer3.ZoomLevelSet.ZoomLevel04.DefaultLineStyle = LineStyles.LocalRoad4;

         layer3.ZoomLevelSet.ZoomLevel04.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        


         layer3.FeatureSource.Open();

         RectangleShape rs = layer3.FeatureSource.GetBoundingBox();

         layer3.FeatureSource.Close();


         

         Map.StaticOverlay.Layers.Add( layer3 );


         Map.CurrentExtent = rs;

         Map.Refresh();



Chad, 
  
   Man that code looks spot on.  Is there any way you can e-mail me the shapefile?  Could you zip it up and send it to support@thinkgeo.com?  I can then look at it myself and see what I can see.  Also please ask them to forward it to David & Ben?  If the file is too big then e-mail support and they can set you up and FTP account.  We are discreet about the data and will delete it when we are finished. 
  
   On another note can you try another shape file?  Could you try switching to decimal degrees and try one of ours in the samples like AusitinStreets? 
  
   We have lots of samples but too many it seems.  It’s hard to find what you are looking for.  Really soon we are going to add a search for it that should really help. 
  
 David

Files were sent via E-mail, let me know if you don't get them.


Also, tried using your AustinStreets with DecimalDegree, same results.  ZoomLevels aren't working with that SHP file either.  Should be easy for you guys to reproduce the problem.


Thanks, Chad



Chad, 
  
 The order of default ZoomLevels in 3.x is different from that in 2.x. In 2.x, ZoomLevel01 represents street level and ZoomLevel18 means country level, while in 3.x to make it consistent with GoogleMap ZoomLevels, we reverse the ZoomLevels order. That’s why although the codes work fine in 2.x but in 3.x as the current ZoomLevel will mostly be in the range from ZoomLevel4 to ZoomLevel20, you cannot see the style changes when you zoom in/out. That’s very easy to be overlooked and sorry we didn’t get that at the very beginning. 
  
 Here with the following codes, you can see the style changes when you zoom in/out. 
  
 
           winformsMap1.MapUnit = GeographyUnit.Meter;

            ShapeFileFeatureLayer layer3 = new ShapeFileFeatureLayer(@"C:\Documents and Settings\yangyong\Desktop\ShapeFiles\streets.shp");
            layer3.RequireIndex = false;

            layer3.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Red,3,true);
            layer3.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level16;

            layer3.ZoomLevelSet.ZoomLevel17.DefaultLineStyle = LineStyles.LocalRoad1;
            layer3.ZoomLevelSet.ZoomLevel18.DefaultLineStyle = LineStyles.LocalRoad2;
            layer3.ZoomLevelSet.ZoomLevel19.DefaultLineStyle = LineStyles.LocalRoad3;
            layer3.ZoomLevelSet.ZoomLevel20.DefaultLineStyle = LineStyles.LocalRoad4;

            layer3.FeatureSource.Open();
            RectangleShape rs = layer3.FeatureSource.GetBoundingBox();
            layer3.FeatureSource.Close();

            winformsMap1.StaticOverlay.Layers.Add(layer3);
            winformsMap1.CurrentExtent = rs;
 
 Thanks, 
  
 Ben. 


Got it seems to work in my simple test.  i'll let you know if i hit any more problems with this.  Thanks for your response.



Great, just let us know for any queries. 
  
 Ben