Export (0) Print
Expand All

Using the MapPoint ActiveX Control

 

Updated July 2004

Applies to:
   Microsoft MapPoint 2002
   Microsoft MapPoint 2004

Summary: Learn about the MapPoint ActiveX control and how to access and run it in Microsoft Visual Basic 6.0. (3 printed pages)

Click here to download the code sample for this article.


Contents

Introduction
Accessing and Using the ActiveX Control

Introduction

The MapPoint ActiveX control gives you all of the functionality included in the MapPoint CD-ROM product. With the ActiveX control you not only have access to the Microsoft base-level map of either North America or greater Europe and included demographic data, but you can also customize the routing and data mapping functions. With MapPoint, Microsoft is offering developers a tool to include maps and location-based information in their solutions. More than 80 percent of all business data has some geographic element. With MapPoint, that data can now be represented on a map to give new insight into your information.

In the MapPoint Office application, we had to stop somewhere. The program was designed for a business user to install and go. To that end, we had to limit some of the functionality, but with the MapPoint ActiveX control you decide the limits. Through the MapPoint object model, you can creatively customize the parameters to import more than 10,000 addresses at a time, create a COM object for importing files from other mapping systems, or find your own way to extend the MapPoint functionality.

Accessing and Using the ActiveX Control

This download provides you with Microsoft Visual Basic 6.0 project files that place the MapPoint ActiveX control on a Visual Basic form. These Visual Basic project files can be used as the starting point for your own custom MapPoint applications. Simply open the project file in Visual Basic and begin adding your own UI components and code to the project.

To run the project, download the components, open the Project1.vbp, and run the project. The sample gives you access to the MapPoint ActiveX Control, which in this application is a simple map that you can pan, zoom and use context-menu commands with.

To create the project

  1. Make sure that MapPoint is installed. When you install MapPoint, the ActiveX control is also installed.
  2. Launch Visual Basic 6.0 and open a new Standard.EXE project.
  3. On the Project menu, click Components.
  4. Click Microsoft MapPoint Control 9.0 and then click OK.

    This adds the MapPoint ActiveX control to the Visual Basic toolbox and provides access to the MapPoint type library. To browse through the MapPoint ActiveX control object model, on the View menu, click Object Browser and then select the MapPointCtl library in the <All Libraries> list.

    Note   When you add the MapPoint ActiveX control to the Visual Basic toolbox, you do not need to reference the main MapPoint type library in Visual Basic.
  5. Select the MapPoint ActiveX control in the toolbox and drag a box onto Form1 to add the control to the form.
  6. Double-click the form (not the control) and add the following code to the Form_Load event:
    Sub Form_Load()
       MappointControl1.NewMap geoMapNorthAmerica
    End Sub
    
    

    This code causes the control to display a North American map by default when the sample runs. If you are using MapPoint Europe, you can display a European map by default by using the following code instead:

    Sub Form_Load()
       MappointControl1.NewMap geoMapEurope
    End Sub
    
    

    The MapPoint ActiveX control works with both MapPoint North America and MapPoint Europe, so you can switch between both maps if you have both versions of the product installed on your computer. You can also load an existing MapPoint map file (.ptm) or template file (.ptt) by using the MapPointControl1.OpenMap method.

  7. Add the following code under the Form_UnLoad() subroutine:
    Sub Form_Unload(Cancel As Integer)
        MappointControl1.ActiveMap.Saved = True
    End Sub
    
    

    This allows the user to make changes to the map without being prompted to save the map when he or she closes the application.

  8. Save and run the project.
Show:
© 2014 Microsoft