ThinkGeo.com    |     Documentation    |     Premium Support

Custom overlayswitcher

Hi,


I need to show a legend of the layers represented on a map. The overlayswitcher is not enough because I've to draw markers, circles, colors related to the layers and put a checkbox beside each of them to manage layers visibility.


I think I can draw the legent with the help of GDI+,  looping through the layers and reading some property.


How can associate checkboxes with layers visibility? Is there any other way to build a legend?


Thanks in advance.


Fabio


 



Fabio, 



OverlaySwitcher is used for switch overlays instead of layers. If you want to switch layers at client side, add only one layer into one LayerOverlay and set its IsBaseOverlay property to false. 


layerOverlay.IsBaseOverlay = false;

Here are just a couple notes. 

1, every layer has an IsVisible property, so you can easily turn it on or off when controlling the layer on server side. 


layer.IsVisible = false;

2, many styles (not all) has a method DrawSample(), which might be easier for you to draw a legend. 



Also let us know for any questions you have, hope you build a great legend. 



Thanks, 



Ben 

 



Ben,  
 do you have any sample of DrawSample method? 
 I’m trying to understand the use of GeoCanvas combined with the DrawSample method, but I’ve some difficulties without a complete documentation. 
  
 Thanks in advance. 
  
 Fabio

Fabio, 


DrawSample is a very low level method which you hardly have chance to use in Desktop Edition. It accepts only one parameter – GeoCanvas, which is similar as the class “Graphs” in GDI+. This method will draw some sample data on the center of the map.
 
Here it is a demo calling the DrawSample methods for LineStyle/PointStyle/AreaStyle and TextStyle. In fact there is a known bug that the PointStyle and LineStyle’s DrawSample methods doesn’t work properly. You will see in this demo.
 
Thanks
 
Ben

440-DrawSampleCSharp.zip (105 KB)