Working with the MapPoint Control in Microsoft MapPoint 2009

Display demographic business data in your applications

Joydip Kanjilal

October 30, 2009

3 Min Read
ITPro Today logo

asp:Feature

Working with the MapPoint Control in Microsoft MapPoint 2009

Display demographic business data in your applications

By Joydip Kanjilal

The Microsoft MapPoint Control is anActiveX control in Microsoft MapPoint 2009 that enables you to embed maps inyour applications seamlessly. You can use this control to leverage the completefunctionality of the MapPoint object model in your applications. This articletakes a look at how you can use this MapPoint in your applications.

MapPoint 2009

Microsoft MapPoint 2009 lets you integrate maps,demographics, and geographical data into custom applications. MapPoint offers thesefeatures:

        Tracks locations in real time

        Maps business data and identify new businessopportunities

        Performs demographic analysis

        Analyzes business performance based on businessand location data

        Integrates maps in Microsoft Office applications

You can find out more about MapPoint 2009 at http://msdn.microsoft.com/en-us/cc905749.aspx.To download a free 60-day evaluation copy of MapPoint North America 2009, go tohttp://www.microsoft.com/downloads/details.aspx?FamilyID=60905dfe-5aea-44ec-b5fb-0e4130c3e7e5&DisplayLang=en.MapPoint 2009 for Europe is also available. MapPoint 2009 European maps containdemographic data for France, Germany, Italy, Netherlands, Spain, Switzerland,and Great Britain/UK.

Getting Started with MapPoint

Once you've downloaded and installed MapPoint inyour system, you can start writing applications using the MapPoint SDK. Here'swhat the opening screen in MapPoint North America 2009 looks like:

Figure 1

The following method demonstrates how you caninitialize the control in your Windows Forms applications:

private voidInitializeMap()

{

if(activeXMapPointControl.ActiveMap != null)

{

activeXMapPointControl.ActiveMap.Saved = true;

activeXMapPointControl.CloseMap();

}

activeXMapPointControl.NewMap(MapPoint.GeoMapRegion.geoMapNorthAmerica);

map =activeXMapPointControl.ActiveMap;

}

As you can see, this code displays the map forNorth America. If you want to display the map for Europe, you can use thefollowing code instead:

private void InitializeMap()

{

if(activeXMapPointControl.ActiveMap != null)

{

activeXMapPointControl.ActiveMap.Saved = true;

activeXMapPointControl.CloseMap();

}

activeXMapPointControl.NewMap(MapPoint.GeoMapRegion.geoMapEurope);

map =activeXMapPointControl.ActiveMap;

}

Here is the complete code:

public partial class Form1 : Form

{

privateAxMapPoint.AxMappointControl activeXMapPointControl;

MapPoint.Map map =null;

public Form1()

{

InitializeComponent();

initializeControl();

}

private voidinitializeControl()

{

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

this.activeXMapPointControl = new AxMapPoint.AxMappointControl();

((System.ComponentModel.ISupportInitialize)(this.activeXMapPointControl)).BeginInit();

this.SuspendLayout();

this.activeXMapPointControl.Enabled= true;

this.activeXMapPointControl.Location = new System.Drawing.Point(0, 0);

this.activeXMapPointControl.Name = "axMappointControl1";

this.activeXMapPointControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMappointControl1.OcxState")));

this.activeXMapPointControl.Size = new System.Drawing.Size(1200, 600);

this.activeXMapPointControl.TabIndex = 0;

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize= new System.Drawing.Size(1200, 600);

this.Controls.Add(this.activeXMapPointControl);

this.Name ="Form1";

this.Text ="Working with Microsoft Map Point Control";

this.Load += newSystem.EventHandler(this.Form1_Load);

((System.ComponentModel.ISupportInitialize)(this.activeXMapPointControl)).EndInit();

this.ResumeLayout(false);

}

private voidForm1_Load(object sender, EventArgs e)

{

InitializeMap();

}

private voidInitializeMap()

{

if(activeXMapPointControl.ActiveMap != null)

{

activeXMapPointControl.ActiveMap.Saved = true;

activeXMapPointControl.CloseMap();

}

activeXMapPointControl.NewMap(MapPoint.GeoMapRegion.geoMapNorthAmerica);

map =activeXMapPointControl.ActiveMap;

}

}

When you execute the application, here's what theoutput would look like:

Figure 2

The MapPoint Virtual Earth Development Platform

The Microsoft Virtual Earth development platform consistsof two web-based services:

        MapPoint Web Service, which uses SOAP and XML.

        The Virtual Earth Map control an ActiveX controlthat can be accessed using AJAX and JavaScript.

The MapPoint Web Service (a location-based service)API is a SOAP API that provides the following functions:

        locating places

        creating routes

        rendering maps

You can use this web service just by referencingthe MapPoint Web Service Description Language (WSDL). Note that you canreference WSDL using either the HTTP or HTTPS protocol. Also, you have two WSDLfiles: one for staging and one for production. Here are the links:

Staging

http://staging.mappoint.net/standard-30/mappoint.wsdl

https://staging.mappoint.net/secure-30/mappoint.wsdl

Production

http://service.mappoint.net/standard-30/mappoint.wsdl

https://service.mappoint.net/secure-30/mappoint.wsdl

Add Mapping to Your Applications

Microsoft's MapPoint enables business houses tovisualize their businesses in an altogether new way: using MapPoint to combinebusiness data with included demographics. I've presented the features of this impressivenew offering and shown you how you can get started using the MapPoint control programmaticallyin your applications.

Joydip Kanjilal is leadarchitect for a company in Hyderabad, India, and is a Microsoft MVP in ASP.NET.He has authored Entity Framework Tutorial(Packt Publishing) and many other books and articles. Joydip blogs at aspadvice.com/blogs/joydip.

Read more about:

Microsoft
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like