An API to Control MapPoint 2006 GPS Features - Part I of II

Eric Frost
08-31-2006, 10:21 AM
Paul Larson shares an API he developed to add programmatic GPS functionality to MapPoint code projects and includes a demo to illustrate how the API works.

"With the release of MapPoint 2006 North America (MP2K6NA) earlier this year, many users have been elated with the new map content and the addition of GPS features and Driving Guidance to the product. Likewise, many developers have thus found issue with the lack of improvement to the MapPoint API, specifically in relation to these new features. Being of the latter group, I decided to roll-my-own API to add programmatic GPS functionality to my MapPoint code projects."

Read the full article --
An API to Control MapPoint 2006 GPS Features - Part I of II - MapPoint Articles - MP2K Magazine (http://www.mp2kmag.com/a137--gps.api.2006.mappoint.html)

Discuss the article in this thread below by clicking on Post Reply (http://www.mapforums.com/newreply.php?do=newreply&noquote=1&p=14066) or use the Quick Reply button on the right.

Paul Larson
09-07-2006, 12:33 PM
I've finally obtained a copy of MapPoint 2006 EUROPE, and noted a slight change needed in the code to handle a difference in this version.

For some reason, Microsoft embedded a CrLf combo in the text of the button to toggle voice prompting. So, in the module mpGPS.vb, in the New() procedure, add the following code:

'EDIT: In mappoint2006 EUROPE, there is a CrLf in the button caption for voice control:
If hwToggleVoice = 0 Then hwToggleVoice = FindWindowEx(hwChild(3), 0, vbNullString, "Turn Voice" & ControlChars.CrLf & "Off (F7)")

...immediately before the line which reads:
hwRepeatLastInstruction = FindWindowEx(hwChild(3), 0, vbNullString, "Repeat Instruction (Spacebar)")

Also, you will of course need to update the sample project (mpGPSDemo) reference for Interop.MapPoint to the correct version when using it with the European desktop product.

Best Regards,
Paul Larson

Eric Frost
09-07-2006, 04:53 PM
Cool thanks, Eric

PC
09-14-2006, 06:46 AM
Wonderful article, thanks.

When will part II be posted.

nprimex1
09-27-2006, 02:03 PM
awesome work ... i'm eagerly waiting for part II.

srogillio
10-03-2006, 01:49 PM
Here is a version I use that is in C#. This code should compile and provide the basic toggling of the GPS Pane. Enjoy

Enigma
11-15-2006, 04:40 AM
Great article, have recompiled for Mappoint Europe and it works fine. Anyone any clues how to extend this to hook the modal warning window pop up when navigation is selected and OK it automatically. Its a really annoying feature of mappoint!.

Cheers Pete

Paul Larson
11-23-2006, 08:02 PM
Hi Enigma

I'm not envisioning distributing the code to dismiss this warning as a part of the API, simply for liability reasons. However, if you contact me directly, I'd be happy to provide a code snippet.

Best Regards,
Paul

Enigma
11-24-2006, 02:58 AM
Hi Paul

Thanks, I have sent you a PM.

Cheers Pete

Paul Larson
12-12-2006, 03:03 AM
Greetings!

Since I've had numerous requests for the code to automatically dismiss the "Safety Warning" dialog when calling my ToggleGuidance() method, I'm posting the code here for public use.

Simply replace the entire routine for ToggleGuidance() with the entire code below. (In module mpGPS.vb)

Note: By using this code you assume full responsibility and risk, and agree not to hold Paul Larson nor Paul Larson, LLC liable for damages.


'---BEGIN CODE---
Public Sub ToggleGuidance()
If lGPS_UseDrivingGuidance = False Then Dim myDismisser As New DismissSafetyWarning
SendMessage(hwProvideDrivingGuidance, BM_CLICK, 0, 0)
lGPS_UseDrivingGuidance = Not lGPS_UseDrivingGuidance
End Sub

Private Class DismissSafetyWarning
Private IsDismissed As Boolean = False
Public Sub New()
Dim myThread As System.Threading.Thread
myThread = New System.Threading.Thread(AddressOf DismissWarningThread)
myThread.Start()
End Sub
Private Sub DismissWarningThread()
Dim Retries As Integer
Dim hwWarning As Integer
Dim hwAgree As Integer
For Retries = 1 To 10
'wait 1/8 of a second
System.Threading.Thread.Sleep(125)
hwWarning = FindWindowEx(GetDesktopWindow, 0, vbNullString, "Safety Warning")
If hwWarning <> 0 Then
hwAgree = FindWindowEx(hwWarning, 0, "Button", "I &Agree")
If hwAgree <> 0 Then
SendMessage(hwAgree, BM_CLICK, 0, 0)
IsDismissed = True
End If
End If
Next
End Sub
End Class
'---END CODE---


Best Regards,
Paul Larson

jonp54
07-05-2007, 09:48 AM
I read Pauls post on his GPS API and though it was the answer to my problems. I am trying to deliver turn messages at the appropriate time but the direction locations do not return an accurate coordinate of the intersection.
So i converted Pauls code to C++ and i called the appropriate functions to get the window handles and toggle the panes. I can even check off the GPS tracking check boxes. However this does not trigger MapPoint to start to read the GPS, it does nothing. Also all the text in the GPS pane is grayed out. This only happens when i open MapPoint from my application. The GPS works fine if i open MapPoint on its own. I noticed with Spy++ that the window was disabled. So i enabled the windows but, still no GPS action.
Am i forgetting something? Has anyone else had success turning the GPS on from code?

Thanks,

Jon

jonp54
07-09-2007, 05:18 PM
Neither mind. I didnt realize i had to use the MapPoint template. However, now i am cant get the turn-by turn direction to update. I create a end waypoint at my destination and then sendMessage to the "F3 Go" button to create a route. This creates a route but the directions dont update based on my location.
Anyone know what i am doing wrong.

Jon

Eric Frost
07-09-2007, 06:04 PM
You may want to ping Paul and see if he can help, see his contact info at the bottom --

An API to Control MapPoint 2006 GPS Features (http://www.mp2kmag.com/a137--gps.api.2006.mappoint.html)

Eric

Eric Frost
07-31-2007, 08:46 AM
Andrew Kun writes about an application he worked on for navigation in police cruisers using techniques from this article..

"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."

Read on at eceblogger.com » Automating MapPoint in C++ with the built in GPS enabled (http://www.eceblogger.com/?p=77)

 
Web mp2kmag.com
mapforums.com