ThinkGeo.com    |     Documentation    |     Premium Support

Zomm Level

How do I set CustomZoomLevel with EcwRasterLayer?

Hello John, 
  
 Sorry I don’t know you are using EcwRasterLayer, ZoomLevel is just used for FeatureLayer instead of RasterLaye whose visibility is controlled by the “upper” and “lower” scale. The ZoomLevel is a kind of manager of scales, different zoomLevel represents different scale ranges. 
  
 All layers inheriting from RasterLayer (EcwRasterLayer, GdiPlusRasterLayer, GeoTiffRasterLayer, MrSidRasterLayer and WmsRasterLayer), basically all image layers, you use the properties LowerThreshold and UpperThreshold to control between what scales the layer is going to be displayed.  
  
 So set your LowerThreshold smaller or set your UpperThreshold bigger will both increase the scale. 
  
 Regards, 
  
 Gary

I already have the LowerThreshold and UpperThreshold set like this 
  
          EcwRasterLayer ecwLayer = new EcwRasterLayer(path); 
          ecwLayer.UpperThreshold = double.MaxValue; 
          ecwLayer.LowerThreshold = 0; 
  
 From my understanding is Google Maps API v3 allows two extra zooms so I installed thinkgeo 6.0 but the max zoom level is still 20. 
  
 Any ideas what I should do now? 


 Kenny,


 
Here is the code of creating 22 zoom levels for the map:
 

double scale = Map1.ZoomLevelSet.ZoomLevel01.Scale;
for (int i = 0; i < 22; i++)
{
    Map1.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(scale));
    scale /= 2;
}

 
Ben
 

How do I make the zoom scale bar on the map be 22 levels as well?

Hello Kenny, 



Once you set the custom zoomlevel to the map, the zoom bar will follow it automatically, so you don't need set any thing for the zoom bar, it will have 22 levels as well. 



Also if you want to modify the zoombar, there is a sample can show you some way. 



 wiki.thinkgeo.com/wiki/Map_Suite_Wpf_Desktop_Edition_Zooming_Panning_Moving_Samples#Customizing_Pan_Zoom_Bar 



Regards, 



Gary



I followed the code to add 22 custom zooms but the zoom bar doesn’t change. It still has 20 clicks. 
 I added a breakpoint before and after adding the zoom level to confirm and indeed it has 22 but not the zoom bar. 
 ANy ideas?

Kenny,


Please try the attached sample, it contains 22 zoom levels and so does the zoom level bar. BTW, the version of dlls is 6.0.0.0 release.


Thanks,


Edgar



CustomizeZoomLevels.zip (391 KB)

I have the GoogleOverlay layer, is that why the custom zoom is not working?



Hello Kenny, 
  
 Could you please provide a sample to us? 
  
 Regards, 
  
 Gary

When I run CustomizeZoomLevels project I can see the 22 zoom levels. 
 If I change the code to the below, the zoom bar is back at 20 zoom levels 
  
  
 GoogleMapsLayer googleLayer = new GoogleMapsLayer(null, ConfigurationManager.AppSettings["GoogleClientID"], ConfigurationManager.AppSettings["GooglePrivateKey"]); 
                 googleLayer.MapType = GoogleMapsMapType.Terrain; 
                 googleLayer.IsVisible = false; 
                 googleLayer.Name = GetLayerName(LayerType.GooglePrint); 
                 googleLayer.CacheDirectory = MapPath("~/GoogleCache"); 
                 googleLayer.ClientId = ConfigurationManager.AppSettings["GoogleClientID"]; 
                 googleLayer.PrivateKey = ConfigurationManager.AppSettings["GooglePrivateKey"]; 
                 googleLayer.TileMode = GoogleMapsTileMode.SingleTile; 
  
  
                 LayerOverlay dynamicOverlay = new LayerOverlay(GetOverlayName(OverlayType.DynamicMap)); 
                 dynamicOverlay.IsBaseOverlay = false; 
                 dynamicOverlay.TileType = TileType.SingleTile; 
                 dynamicOverlay.TransitionEffect = TransitionEffect.None; 
                 dynamicOverlay.Layers.Add(googleLayer.Name, googleLayer); 
  
                 GoogleOverlay googleMap = new GoogleOverlay(GetOverlayName(OverlayType.GoogleMap)); 
                 string googleUri = ConfigurationManager.AppSettings["GoogleUri"]; 
                
                 googleMap.JavaScriptLibraryUri = new Uri(googleUri); 
                 googleMap.GoogleMapType = GoogleMapType.Physical; 
                 googleMap.IsVisible = true; 
                 googleMap.Name = "GoogleMapsOverlayName"; 
                 googleMap.IsBaseOverlay = true; 
  
                 Map1.MapUnit = GeographyUnit.Meter; 
                 Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962); 
                Map1.CustomOverlays.Add(googleMap);  
                 Map1.CustomOverlays.Add(dynamicOverlay); 
                 Map1.ZoomLevelSet = GetCustomZoomLevelSet();

Kenny, 
  
 The ZoomLevelBar must be consistent with the base overlay, which means if GoogleOverlay is set to be the base, ZoomLevelBar must has 20 levels, the same as what GoogleMaps has. If you add a GoogleMapsLayer to a LayerOverlay and use that as the baseoverlay, the ZoomLevelBar can be 22. (GoogleMapsLayer is slower so that’s in fact not what we recommended.)  
  
 I also read that Google Maps allows a max zoom level of 22 in v3 only when the map type is Satellite,(stackoverflow.com/questions/2628940/does-google-maps-api-v3-allow-larger-zoom-values) however I didn’t see it when browsering the GoogleMaps through OpenLayers, or even in its own web site. (maps.google.com) so where do you get the 22 thing? Please let me know more about it and we could be helpful. 
  
 Thanks, 
  
 Edgar 


Look at this page, it uses Google Maps API V3 directly, no thinkgeo component.



Kenny,


 
Sorry to tell you that we only support custom zoom levels in LayerOverlay, because we use the Openlayers as our JavaScript library, and we cannot modify the zoom levels. If you want to display more than 20 zoom levels and use Google map as base map, you can try this code:

public class MyZoomLevelSet : GoogleMapsZoomLevelSet
{
public MyZoomLevelSet()
:base()
{
double scale = ZoomLevel01.Scale;

//currently we can get the image in zoomlevel 22 from Google
for(int i = 0; i < 23; i++)
{
CustomZoomLevels.Add(new ZoomLevel(scale));
scale /= 2;
}
}
}


Map1.ZoomLevelSet = new MyZoomLevelSet();


But the speed is lower than using GoogleOverlay.
 
Hope this helps,
 
Edgar
 

openlayers.org/blog/2010/07/10/google-maps-v3-for-openlayers/ 



var ghyb = new OpenLayers.Layer.Google( 

"Google Hybrid", 

{type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20} 

// used to be {type: G_HYBRID_MAP, numZoomLevels: 20} 

); 



Isn't the number of zoom level a variable that you guys can pass to open layer?


It also looks like that I should be getting the extra zoom level in satellite mode and it is not the case for this version 6 either.


openlayers.org/dev/examples/google-v3.html



 Kenny,


Thank you for your post, you can add the attached code scope to the aspx file, and please make sure your google overlay is base overlay.


Regards,


Edgar


 



code.zip (331 Bytes)

We are getting closer but not there yet. The code works in the sense that there are now 22 zoom levels on the zoom bar.


A few questions


 


1)  Ecw layer is not showing up in zoom level 21 & 22




                    EcwRasterLayer ecwLayer = new EcwRasterLayer(path);

                    ecwLayer.UpperThreshold = double.MaxValue;

                    ecwLayer.LowerThreshold = 0;

                    ecwLayer.IsVisible = true;


 


2) Do I need to use customzoom?


3) What do I do with existing code that uses the constant ApplyUnitlZoomLevel.Level20?



Kenny,


 
Here are the answers:
 
1&2, yes you need to use the custom zoom levels.
 
3, if the layer uses custom zoom levels, the style must be set to every zoom level, e.g. 
 

layer.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(scale /= 2) { DefaultAreaStyle = AreaStyles.Country1 });
layer.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(scale /= 2) { DefaultAreaStyle = AreaStyles.Country2 });

 
And the ApplyUnitZoomLevel will not be used.
 
Regards,
 
Edgar

Is there a better way of doing this custom zoom levels if we have 20+ layers?

Kenny,


You can do it in a loop:



ZoomLevelSet zoomLevelSet = new ZoomLevelSet();

for(int i = 0; i < zoomLevelCount; i++)
{
zoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(maxScale /= 2){ DefaultAreaStyle = AreaStyles.Country1 });
}

foreach(var layer in layers)
{
layer.ZoomLevelSet = zoomLevelSet;
}

 


Regards,


Edgar