VE Team
09-21-2007, 06:22 PM
<p>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 <a href="http://veteam.members.winisp.net/ColSelect/CollectionSelector.htm" target="_blank">this simple app</a> 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: <p><font face="Courier New">var l = new VEShapeLayer();***** <br>var veLayerSpec = new VEShapeSourceSpecification(VEDataType.VECollection , "89202C9BEAFA5F9!450", l);*********** <br>map.ImportShapeLayerData(veLayerSpec, fnLayerLoaded);</font> <p>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 <a href="http://dev.live.com/virtualearth/sdk/" target="_blank">VE interactive SDK.</a> <p><a href="http://veteam.members.winisp.net/ColSelect/CollectionSelector.htm" target="_blank"><img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=317 alt=image src="http://byfiles.storage.msn.com/y1pTcqBXnZTBA-tn-b1QGwMgaGdqDSQNo3L0jXw78NhoYKes7xMkYiB1My0A6mk01RN ol2gzXF9LNw?PARTNER=WRITER" width=590 border=0></a> <div style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px">Technorati tags: <a href="http://technorati.com/tags/Virtual Earth" rel=tag>Virtual Earth</a>, <a href="http://technorati.com/tags/developer" rel=tag>developer</a></div> <p>Currently <em>Threshold Apprentice </em>by <a href="http://music.msn.com/search/all/default.aspx?ss=Black Francis">Black Francis</a> is playing <img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3151506992847969176&page=RSS%3a+Layer+switching+in+Virtual+Earth+Apps&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&NA=1149&PI=88469&RF=&DI=3919&PS=85545&TP=virtualearth.spaces.live.com>1=virtualearth">
Click here to view the article. (http://virtualearth.spaces.live.com/Blog/cns!2BBC66E99FDCDB98!9167.entry)
Click here to view the article. (http://virtualearth.spaces.live.com/Blog/cns!2BBC66E99FDCDB98!9167.entry)