Share via


Using Virtual Earth With Published Collections

Last year I started working on a side project to keep track of my family.  I stopped at some point because I didn't want to put too much information on the public site.  Now that v6 of the Virtual Earth control is out, I have picked the project back up again.  I wanted to make the data easier to maintain and be able to protect certain pieces of data.

imageAfter moving it to its own site, I got rid of the array so I could replace it with maps.live.com collections.  To create a collection, simply open maps.live.com.  In the top-right corner is a "Collections" option.  Clicking this allows you to create or view your collections.  I created a new collection for my family.  Adding individuals is even easier.  You can add data to the collection by from the map by right-clicking & selecting "Add a pushpin."  When the form pops up to edit data on your pushpin, you can add the pin to the relevant collection.

 

Once you have a collection (and you can always edit, delete, add to the collection in the future), you can bring that data onto a map.  The following code actually imports the layer:

              function AddMyLayer(type)
              {
                  var l = new VEShapeLayer();
                  var veLayerSpec = new VEShapeSourceSpecification(type, collectionID, l);
                  map.ImportShapeLayerData(veLayerSpec, onFeedLoad, false);         
              }

Type is which type of shape you're bringing in - in this case you want VEDataType.VECollection.

onFeedLoad is just a callback that executes after the layer is added.

So now we just need the collectionID. I'm sure there is an easier way to do this, but I didn't find it and this was pretty fast anyway. What I did was click on my collection and under "Actions" select "Send in e-mail." The e-mail will pop up with a hyperlink to send. Pull out the string between "cid=" and "&encType" and that's your collectionID. Embed that in the script file and you're good to go!

image

Next on the agenda is adding Windows Live ID Authentication to the site! You can follow the site's progress here.

Cross posted from Martha's Blog