Project54 & Software & Tips and tools Jonathan Oppelaar on 30 Jul 2007 12:28 pm
Automating MapPoint in C++ with the built in GPS enabled
Project54 is currently developing a GPS Navigation application to be used in police cruisers. This navigation application is using MapPoint 2006 as its routing and mapping engine. MapPoint 2006 has an SDK which gives developers software control of MapPoint. With this SDK Project54 developers are able to integrate MapPoint into the Project54 system. However, there are a few limitations to MapPoint’s SDK that need to be resolved before MapPoint can be installed in a car.The first limitation is that there are no API calls to turn GPS Tracking on or off. GPS Tracking is a MapPoint feature that reads data from a GPS receiver and displays your current position on the map. This feature also has the ability to rotate the map, which cannot be done via APIs.
Driving Guidance is another MapPoint feature that cannot be controlled by the SDK. Driving Guidance displays turn by turn directions while a user is driving along a route. These directions are also presented to the user through speech. A status bar is shown to keep the user up to date with progress on a certain road segment.
These limitations must be overcome if we want to use MapPoint as the navigation backbone in the Project54 system. This post is about my workaround to MapPoint’s SDK that allows developers to enable MapPoint’s GPS Tracking and Driving Guidance.
I chose to develop a solution in C++ because I am most familiar with that language and Project54 applications are written using C++. Unfortunately for C++ developers, almost all resources for MapPoint are given in C# and VB. Since Project54 is COM based it would have been possible to write an application using C# or VB and incorporate it into Project54 but, that is not as clean of a solution and would require more work.
After researching my problem on the Internet I was able to find an article that uses Windows messages to control MapPoint. In this article Paul Larson describes his API in VB that can control MapPoint’s window panes as well as the check boxes in the panes which enables the GPS Tracking and Driver Guidance. I also found an article that gives an example on how to automate MapPoint in C++.
With the combination of these two articles and other resources I was able to write an application that integrates MapPoint into Project54. Unfortunately, even after enabling the Driving Guidance by help of Paul Larson’s code, the turn by turn directions would not update. The only message given by the guidance was “Proceed to Route”. This seemed odd to me because the turn by turn direction update perfectly when I would run MapPoint.exe outside of Project54.
This led me to try something different than what is the suggested way to start MapPoint. Every example I have come across initializes MapPoint using the CreateInstance(LPSTR clsid) (in C++) or the CreateObject(LPSTR clsid) (VB) function call. This returns a COM pointer to the MapPoint application. You need this pointer in order to call any of MapPoint’s APIs. My approach was to use CreateProcess(LPSTR path) to open MapPoint.exe and then get a pointer to the application that is already running. I am able to do this by calling the GetActiveObject(LPSTR clsid) function. This function returns the application pointer to an active COM object.
Now that MapPoint is initialized differently, the Driving Guidance works perfectly. Also, no other code has to be altered. I cannot tell you why the driving directions did not work with the original solution but, I can tell you that when the new method is applied there are no issues enabling the GPS Tracking and Driving Guidance by windows messages. Here is a screenshot of working turn by turn directions in the Project54 software:
Jon Oppelaar


on 02 Aug 2007 at 12:11 pm 1.andrewkun said …
Will your navigation application display OK on different resolution screens in P54-equipped cruisers?
on 08 Aug 2007 at 9:50 am 2.Jon Oppelaar said …
Unfortunately no. According to MapPoint’s documentation the screen resolution has to be at least 1024×768. I ran some tests to see how my application would behave when I changed my screens and P54GUI’s resolution. There are no problems at 1024×768. At 800×600 the status bar which shows your diving progress is cut off. At 640×480 the status bar, direction symbol and part of the turn by turn direction gets cut off. Instead of shrinking the window size MapPoint truncates the window as the resolution changes. I would recommend that the officers’ screen resolution to be set at 1024×768. However, if they don’t mind losing the progress bar they can get away with 800×600.