Partager via


Creating a Hello World plugin for Virtual Earth 3D

With latest release of the Virtual Earth 3D release we now support loading plugins to perform additional functionality not implemented in the main product. Two new features of the release are even implemented as plugins (bird's eye photos and user created models).

To get you started with creating your own plugin for VE3D here's a short starter guide using Visual Studio 2005.

  1. Create a new C# Class Library project, call it HelloWorld.

  2. Add references to the following assemblies located in C:\Program Files\Virtual Earth 3D:

    • Microsoft.MapPoint.Rendering3D.dll
    • Microsoft.MapPoint.Rendering3D.Utility.dll
  3. Rename Class1.cs to HelloWorldPlugin.cs and paste the following code over the file:

    using System;

    using System.Collections.Generic;

    using System.Text;

     

    using Microsoft.MapPoint.PlugIns;

    using Microsoft.MapPoint.Rendering3D;

     

    namespace VirtualEarth3DSamplePlugins.HelloWorld

    {

        public class HelloWorldPlugin : PlugIn

        {

            #region Constructor

            public HelloWorldPlugin(Host host)

                : base(host)

            {

            }

            #endregion

            #region Overrides

            public override void Activate(object activationObject)

            {

                this.Host.Notifications.Display("Hello world!");

     

                base.Activate(activationObject);

            }

            public override string Name

            {

                get

                {

                    return "HelloWorldPlugin";

                }

            }

            #endregion

        }

    }

  4. Go to Project Properties, Signing, check Sign the assembly and create a new key to sign your project with. Only plugins that are in the GAC will be granted permissions to run and only strongly named assemblies may be placed in the GAC.

    Build your project and copy HelloWorld.dll to a new folder named C:\Program Files\Virtual Earth 3D\Plugins\HelloWorld. From a Visual Studio 2005 Command Prompt run
    gacutil -i "C:\Program Files\Virtual Earth 3D\Plugins\HelloWorld\HelloWorld.dll"

Now start up 3D mode on maps.live.com and you should see a notification upon startup from the hello world plugin.

 That's it for creating a simple plugin. If you want to explore further on your own the Host object contains all the interfaces for a plugin to communicate with VE3D.

Mandatory disclaimer so I don't get into trouble: creating plugins is not officially supported.