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 2009
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 2009

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
ViaVirtualEarth
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

Travel Insurance Compare over 450 travel insurance policies (inc. annual multi-trip, single trip & winter sports)

  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
-Help with Spatial Data/Table. Sql add-in Mappoint
-Matching by Zip Code
-Another Big Imagery Release for Bing Maps
-BingMapsDev: @csharpzealot and the 2.3GB download begins ;)
-BingMapsDev: Great new book in French on Bing Maps from @NicolasBoonaert http://bit.ly/ba72nc
-bingmaps: MapDotNet's entry to Azure US State and Local Government Application Development Contest with Bing Maps: http://miami311.cloudapp.net/
-Ability to change color of state lines?
-bingmaps: @chrispendleton on stage right now at TechDays in Paris. Presenting #BingMaps
-route directions????
-bingmaps: Interested in the rare trees of London? View them in this #BingMaps collection http://bit.ly/chOLp9
-MapPoint in Desktop Applications
-Varying travelling time by "time of day"
-Link using parameter query in Access, still no?
-Can I see a list of all pushpins?
-Assigning pushpins as territories
-Displaying info in the directions for a route
-Drive time polygons - help needed
-2002 Loading Help
-bingmaps: Webcast 10th Feb: #BingMaps ? Getting Started for Developers. Presented by @johanneskebeck http://bit.ly/8XhzCC
-bingmaps: Vancouver applications feature #BingMaps, just in time for the winter Olympics http://bit.ly/b0FoRj
-Vancouver Applications Feature Bing Maps
-Distance between locations
-bingmaps: Arlington, Virginia is using Bing Maps to help drive economic development. Check it out: http://bit.ly/1JCqpi
-bingmaps: Check out this cool video of US Navy (ONR) using Bing Maps for mobile command & control: http://bit.ly/3Jo2MX
-bingmaps: US Navy testing mobile command & control solution using Bing Maps & Windows Mobile phones. Case study: http://bit.ly/XEuF9
 Resources
Browse GIS books and periodicals
Best Car Contract Hire Lease Save
Find a MapPoint Partner or Consultant
Real Estate Columbia MO Homes for Sale


Want Your Site To Appear Here?

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

• Replacement Cordless Phone Batteries from DSMiller
Improve your career with a computer degree LocalEDU.com
• Tim Cohn's Marketing Strategy Consultancy
• Buy Toner Cartridges at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards • The Search Starts Here Used Cars
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars UK, Car Lease and Contract Hire