Working with the MapPoint Control in Microsoft MapPoint 2009

Display demographic business data in your applications

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 an ActiveX control in Microsoft MapPoint 2009 that enables you to embed maps in your applications seamlessly. You can use this control to leverage the complete functionality of the MapPoint object model in your applications. This article takes 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 these features:

         Tracks locations in real time

         Maps business data and identify new business opportunities

         Performs demographic analysis

         Analyzes business performance based on business and 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 to http://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 contain demographic data for France, Germany, Italy, Netherlands, Spain, Switzerland, and Great Britain/UK.

Getting Started with MapPoint

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

Figure 1

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

private void InitializeMap()

{

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 for North America. If you want to display the map for Europe, you can use the following 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

{

private AxMapPoint.AxMappointControl activeXMapPointControl;

MapPoint.Map map = null;

public Form1()

{

InitializeComponent();

initializeControl();

}

private void initializeControl()

{

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 += new System.EventHandler(this.Form1_Load);

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

this.ResumeLayout(false);

}

private void Form1_Load(object sender, EventArgs e)

{

InitializeMap();

}

private void InitializeMap()

{

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 the output would look like:

Figure 2

The MapPoint Virtual Earth Development Platform

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

         MapPoint Web Service, which uses SOAP and XML.

         The Virtual Earth Map control an ActiveX control that 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 referencing the MapPoint Web Service Description Language (WSDL). Note that you can reference WSDL using either the HTTP or HTTPS protocol. Also, you have two WSDL files: 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 to visualize their businesses in an altogether new way: using MapPoint to combine business data with included demographics. I've presented the features of this impressive new offering and shown you how you can get started using the MapPoint control programmatically in your applications.

Joydip Kanjilal is lead architect 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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish