spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2013
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  ARTICLES  


MapPoint Graticule COM Add-in

This article describes a Visual Basic 6 COM add-in for MapPoint 2002 that draws parallels and meridians at spacings of 15 degrees on any MapPoint .ptm map. Geographers commonly refer to this grid as a graticule.

Introduction

When viewing maps in MapPoint 2002, particularly if Globe View when Zoomed Out is selected, the three-dimensional rendering of the map is significantly improved if parallels and meridians are visible on the map. A sample map showing the parallels and meridians can be seen by going to the MP2K gallery. The Prime Meridian and the Equator are shown with a heavier weight line to more clearly demark the starting points for measuring latitude and longitude. Indeed, with parallels and meridians drawn, the map really looks like the globe that all of us remember from our days of studying world history and geography as youngsters. Printed versions of the map look even better, as the parallels and meridians are then drawn at printer resolution, resulting in very smoothly curved lines.

The first time around, this was written as a stand alone .exe and took more than one minute to draw the entire grid on a Pentium III at 750 MHz. When changed into a COM add-in the time was reduced to less than 15 seconds. This clearly shows the speed advantage of a COM add-in running in-process with MapPoint 2002.

The COM Add-in

The primary MapPoint 2002 method used in this COM add-in is the AddLine method. The syntax for this method is:

object.AddLine(BeginLocation, EndLocation)

This method returns a shape object with a type property of geoLine. BeginLocation is a location object indicating the starting point of the line and EndLocation is a location object indicating the ending point of the line.

The key to understanding how this COM add-in works is knowing the precise meaning of the concept of a geoLine. A geoLine is not a straight line and it is not just any curved line either. A geoLine is a portion of a great circle route on the globe. A great circle is any circle that divides the earth into two equal halves. The most obvious great circle is the equator that circles the earth in the tropics at zero degrees latitude. Each meridian is half of a great circle, running from North Pole to South Pole.

As a result, it is quite easy to draw meridians using the MapPoint 2002 AddLine method. Drawing the parallels is a bit more challenging however, as they are not great circles (with the exception of the Equator, which, as mentioned above, is a great circle). The 49th parallel, famous as the boundary separating the northwest part of the United States from Canada, for example, would not divide the Earth into two equal halves if extended around the Earth.

If a parallel is constructed by drawing a large number of great circle routes between points that are relatively close together, then the result is visually that of a true parallel. The Visual Basic 6 code for the cmdDrawGrid_Click() subroutine shown below, and used in the COM add-in, constructs each parallel by drawing great circle routes between points that are separated by 2 degrees. Thus, each parallel consists of 180 "small" great circle route segments.

The code for the designer class Connect is shown below. In a nutshell, it deals with two events:

  • The OnConnection event, which occurs when the COM add-in is loaded (connected)
  • The OnDisconnection event, when the COM add-in is unloaded (disconnected).

This designer code, with small modifications only, is the same as that supplied by Microsoft MapPoint 2002 in its Help/Microsoft MapPoint Help/Programming Information/Using COM Add-ins/Creating COM Add-ins/Create COM add-in in Visual Basic.

Downloadables

The downloadable DrawGrid.zip contains four files related to this COM add-in:

  • DrawGrid.vbp
  • DrawGrid.frm
  • DrawGrid.Dsr
  • DrawGrid.dll
After downloading DrawGrid.zip, extract the four files to a local directory on your machine.

The first three of these files can be used within Visual Basic 6 and are provided for those who may wish to make changes that extend the capabilities of this COM add-in. Some reasonable extensions include the ability of the user to specify how far apart to draw the grid lines (in degrees, minutes, and seconds), as well as the ability to specify range (i.e. minimum and maximum) for latitude and longitude grid lines that are to be drawn.

For those of you who just want to get the grid lines as described in this article on some of your MapPoint maps ASAP, DrawGrid.dll is for you! Simply follow these steps:

  1. With MapPoint 2002 open, click on Tools/COM Add-ins.
  2. Click the Add... button in the COM Add-ins dialog box, navigate to DrawGrid.dll, and click on the Open button in the Open dialog box. Draw Grid will then appear in the COM Add-ins dialog box and will be checked. Click the OK button. (Steps 1 and 2 will no longer be necessary in the future, as the DrawGrid COM add-in will automatically load when MapPoint 2002 is started.)
  3. To draw the grid, click on Tools in the main menu and then on Draw Grid, which is now shown on the drop down menu below COM Add-ins.
  4. On the Draw Grid dialog, click on the Draw Grid button. The cursor will change to an hour glass, and within a few seconds (the exact time depending upon the speed of your computer), the grid will appear on your map.

Discuss this story in the forum.

Author: Rich Born
Email: rborn(AT)niu.edu
Rich Born is an Associate Professor in the Department of Operations Mangement and Information Systems in the College of Business at Northern Illinois University (NIU). Rich teaches courses in business applications of geographic information systems and computer simulation in business at both the undergraduate and graduate level. In an effort to provide insight into the benefits of mapping business data, Rich has set up a Business Geographics Center at NIU.



Google
 
MP2Kmag Internet


 Recent Discussion
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Thornbrook Homes for Sale


Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.