ThinkGeo.com    |     Documentation    |     Premium Support

Different style for features in the same zoom level

Hi, 


I would like to know if it's possible to configure the drawing style of features (in this case, roads)  in the same zoom level in the same shapefile. 


For instance, I want the highways to be drawn differently from normal roads, in the same zoom level. 


Is there a way to configure the style conditionally, based on the road attibutes?


I also want to control which cities are shown at a certain zoom level. For example, when the map is far away I just want to show the capitals, and when I zoom in I want to show the cities progressevely based on its population or importance. Is it possible to achieve that using just one shapefile?


Thanks


 


 



Yes, you can configure the style conditionally, based on the road attributes. You would need the ValueStyle for this. I suggest you check out the sample app “Draw Features Based On Values” of the “How Do I” apps. Also, there a recent project of the Code Community that shows how to use ValueStyle: 
 code.thinkgeo.com/projects/show/valuestylecountries 
  
 One project is using point based layer and the other one is using a polygon based layer, but I think that you will get the idea on how to use that style for your case. 
  
  
 For your other question on displaying a layer differently based on the zoom level, the answer is also YES.  
  
 For example, you can have a layer for cities. At the highest zoom level, you use a regular style to display all the feature the same way. At lower zoom levels, you can use a Value Style or a ClassBreakStyle to show differently the feature based on the population. I don’t think we have a specific app in the “How Do I” sample apps or in the Code Community. But I think this will be a good idea to present such a project to the community and we will post one soon. Thank you for your idea. 
  
  You need to look at the ZoomLevelSet property of Layers to adjust the styles based on the zoom levels. 
  
  worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));    
 worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;    
  
  If this is still not very clear, let us know and we will hurry up to create a new project on that topic for the Code Community.