Want to try custom code for the 3D view of Virtual Earth? This is the place to find out how!
What do I need?
· Virtual Earth 3D installed. Navigate to maps.live.com, click the 3D button, and follow the upgrade/install steps.
· Visual Studio 2005 and some c# coding skills.
· This package.
Extract the samples zip to c:\Samples (or any other directory, but you'll have to fix up some paths in the projects). There's a Readme, but you should be able to just open the sln in Visual Studio, set one of the projects to the Startup project, and hit F5. For this post, we'll just talk about the basics of how the plug-in will be loaded.
Try building and launching the project SimpleObjectPlacement.

By default, you'll get an IE window with a script warning. This only happens because we're loading the html off the local drive, and will not happen if we point to a web server.

You can change startup behavior by modifying the values in the Debug pane of the project.

Once there you should see the globe, and after a moment it will zoom to off the coast of Africa to see a floating cube.

So what happened? First, we have a very simple webpage that loads the JavaScript SDK, and then extracts the 3D control from it to do some special loading. This is an unsupported thing to do (well heck, everything in these samples is unsupported, but that doesn’t mean it won’t work), but we need to get at the Events and LoadPlugInDll methods.
map = new VEMap('myMap');
map.SetDashboardSize(VEDashboardSize.Normal);
map.LoadMap(null, 2, 'a', false, VEMapMode.Mode3D);
control3D = map.vemapcontrol.Get3DControl();
control3D.AttachEvent("OnPlugInLoaded", "On3DPlugInLoaded");
control3D.AttachEvent("OnPlugInActivated", "On3DPlugInActivated");
control3D.AttachEvent("OnPlugInDeactivated", "On3DPlugInDeactivated");
control3D.LoadPlugInDll("C:\\Samples\\SimpleObjectPlacement\\bin\\Debug\\SimpleObjectPlacement.dll");
Events are just callbacks when certain things happen. In this case, when a plug-in is finished loading the SDK will try to call a function called "On3DPlugInLoaded". It has to be this way because the LoadPlugInDll method is asynchronous -- otherwise we'd have to sit and wait for loading to complete, causing a negative user experience. But you don't have to worry much about this, just know that you can listen to events and you'll be called when things happen. You can also fire your own events, which we'll get to later. In this case, if you look at the handler you'll see when we finish loading the plug-in we'll activate it. We could do more, but this is the minimum.
You can specify a plug-in to load in two ways. First is like this, with a local file path. Second is by specifying the fully qualified name. Either method requires that the plug-in be installed in the GAC, which is an unfortunate security limitation that we hope to relax in the future. You can get installed into the GAC by using utilities that come with VS, or by writing an MSI installer. We'll get into more on that later. All the samples here install their output into the GAC as a post-build step to help you get past these details.
When the plug-in is loaded, then we start executing the C# code. If you put breakpoints in SimpleObjectPlugIn.cs, you'll see it gets a call to the constructor, and then one to the Activate function. In a future post we'll walk through the details of what happens next, how the cube gets into the world, and why it changes color when you mouse over it. In the meantime, try playing with the other samples. Let us know what you think, and please enjoy.
Download Samples.zip