A common question from developers just getting started with the Virtual Earth platform is how to control turning multiple layers on and off. I received this question again yesterday so I put together this simple app as an example. The sample starts by loading three layers from existing Collections. These layers can be just as easily loaded from GeoRSS feeds or created programmatically on the fly. Loading a layer in VE is this simple:

var l = new VEShapeLayer();*****
var veLayerSpec = new VEShapeSourceSpecification(VEDataType.VECollection , "89202C9BEAFA5F9!450", l);***********
map.ImportShapeLayerData(veLayerSpec, fnLayerLoaded);

Each layer loads asynchronously and fires the specified callback when it completes. fnLayerLoaded in this case. Your call back is passed the corresponding VEShapeLayer for you to do whatever post processing you want to. in my case I formatted an HTML list of the data and set a custom icon for each layer. The list control above the map is used to switch layers. for a reference of all of the layer operations checkout the VE interactive SDK.


Technorati tags: ,

Currently Threshold Apprentice by Black Francis is playing

Click here to view the article.