ThinkGeo.com    |     Documentation    |     Premium Support

Changes in Layers/Overlays

Hi all,


Since the latest build of MSWE, I've been having a difficult time sifting through the changes in the layers.  Right now, for instance, I'm using ShapeFileFeatureLayers, where before I would use ShapeFileLayers.  As I understand it, the changes between these two types are minimal, as both are static overlays, correct?  My large problem comes in with the MarkerLayer changes.  Previously, I could create a MarkerLayer, and add it to a map as a MarkerLayer, instead of an InMemoryLayer.  Now, since it seems I need to use InMemoryMakerLayer, I have to add the layer as a CustomOverlay, which seems to be making my StaticOverlays not work at all.  Is there something I'm doing wrong, or are the changes intentionally doing this? Code follows:


 


 



MainMap.MapUnit = GeographyUnit.DecimalDegree;
MainMap.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"));
MainMap.RestrictedExtent = new RectangleShape(new PointShape(-180, 90), new PointShape(180, -90));
MainMap.MapTools.PanZoomBar.Enabled = false;
MainMap.MapTools.Logo.Enabled = false;
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer((@"D:\Program Files\ThinkGeo\Map Suite Web Full Edition 3.0 (BETA)\Samples\CSharp Samples\SampleData\World\cntry02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
MainMap.StaticOverlay.Layers.Add(worldLayer);
MarkerOverlay markerOverlay = new InMemoryMarkerOverlay("Markers");
MainMap.CustomOverlays.Add(markerOverlay);
MainMap.CurrentExtent = new RectangleShape(-180, 90, 180, -90); 


Dustin, 
  
 In the current version (3.0.131), there are 2 ways to use Overlays. One is “simple mode” by using map’s existing overlay properties. For example, you can set static/dynamic overlays by Map.StaticOverlay or Map.DynamicOverlay, and set markers by Map.MarkerOverlay. The other way is “custom mode” in which you need to create an Overlay and add it to property Map.CustomOverlays. This is more advanced and you can implement some functions the “simple mode” can hardly accomplish. (ex: you can create and add a featureMarkerOverlay which cannot be added in “simple mode”). One thing to aware is that the 2 modes are “one or the other”, if you add anything to custom overlay, system will think you are now in “custom mode” and will ignore all the specific overlay properties. That’s why your code doesn’t work. If you want to use the “simple mode”, just avoid creating your own markerOverlay and use Map.MarkerOverlay instead.  
  
 There is no markerlayer any more, instead, it has markerOverlay. You can still create your own InMemoryMarkerOverlay in “custom mode” or add features directly to Map1. MarkerOverlay in “simple mode”. We changed the name from ShapeFileLayer to ShapeFileFeatureLayer because as it is inherited from FeatureLayer, that’s clearer to have that suffix. 
  
 BTW: we will have the full edition released pretty soon, that will have some breaking change for the existing one and we will provide some documentation for all the changes.  
  
 Any queries please let me know. 
  
 Ben. 


That makes a ton more sense now Ben.  Thanks very much for that! 



One more question, though. Is there an equivalent layer type in 'custom mode' for Static Layers? Simple mode looks like it'll get the job done, but I think I'd rather have the flexibility of the advanced mode in preparation for future growth of the project.  I've looked at the examples from the live demo (specifically the 'Add a Marker' demo) and both the StaticOverlay and InMemoryOverlay are showed being used simotaneously.  Is this in error?  As I understand your previous comments, they are not supposed to be used in the same context.  


Furthermore, is there a synopsis of layer types and their accompanying 'mode' to be found anywhere?  A 'quick reference' guide, of sorts, would be a wonderfully useful tool for your product!  I've tried to submit myself to looking through the API, but there's just far too much information there to digest properly.



Dustin,


First want to let you know the Web Edition was final released earlier today. Please try the latest one and my sample codes is based on that version.


I am sorry that our live examples are not up to date. In our latest WebEdition, we clearly separate these two modes.


In “custom mode”, the equivalent type for the StaticOverlay is the LayerOverlay with the IsBaseOverlay property set to true.  And the equivalent one for the DynamicOverlay is a LayerOverlay with its IsBaseOverlay property set to false.  The LayerOverlay is a kind of overlay to which you can add layers, such as ShapeFileFeatureLayer and InMemoryFeatureOverlay, and it renders these layers to one image. The IsBaseOverlay property determines whether this overlay is a base map or can overlap on other overlays.  You can create any number of LayerOverlays and add them to the CustomOvelrays collection.

LayerOverlay worldOverlay = new LayerOverlay("WorldOverlay");
worldOverlay.IsBaseOverlay = true;
worldOverlay.Layers.Add(worldLayer);
//Continue adding your layers…
 
LayerOverlay roadOverlay = new LayerOverlay("RoadOverlay");
roadOverlay.IsBaseOverlay = false;
roadOverlay.Layers.Add(roadLayer);
//Contine adding your layers…
 
LayerOverlay shapeOverlay = new LayerOverlay("ShapeOverlay");
shapeOverlay.IsBaseOverlay = false;
//Add your layers…
 
Map1.CustomOverlays.Add(worldOverlay);
Map1.CustomOverlays.Add(roadOverlay);
Map1.CustomOverlays.Add(shapeOverlay);
 
In our current WebEditon, we introduce the concept of overlay that is different with the concept of layer. For more information about overlays, please reference this post:
 
            gis.thinkgeo.com/Support/Dis...fault.aspx
 
Thanks,
 
Ben 

 



Thanks Ben.  Just as helpful as always.  That sheds quite a bit of light on the situation.

Always my pleasure, Dustin, let us know if there is anything we can do to make your coding easier.