[AccessD] Any MapPoint programmers out there?

paul.hartland at fsmail.net paul.hartland at fsmail.net
Fri Jun 3 06:49:51 CDT 2005


Thanks very much, I can start playing now.....





Message date : Jun 03 2005, 12:46 PM
>From : "Michael R Mattys" 
To : "Access Developers discussion and problem solving" 
Copy to : 
Subject : Re: Re: [AccessD] Any MapPoint programmers out there?
Paul,

I pulled this from an answer on Google
Author is Gilles Kohl (MVP)
************************
>In my custom software I need to provide driving distance and directions
>between any 2 addresses (a map would be nice too). Does MapPoint have an
API
>that I can hook into so I can integrate these features in my software?

Yes it does, no problem. And in case you won't take my word for it,
here's sample code that works with MapPoint 2001 (to prevent
word-wrapping problems, I've also attached it as a text file)

For a map, you could either use the CopyMap method of the Map object
(copies the map as a picture to the clipboard, use like so:

objMap.CopyMap
Image1.Picture = Clipboard.GetData
), or use the full-blown MapPoint ActiveX control available in
MapPoint 2002.

Hope this helps,

Regards,
Gilles.

Option Explicit

' remember to set a reference to the Microsoft MapPoint Object Library
(North American)
Dim objApp As New MapPoint.Application

Private Sub cmdCalcDistance_Click()
Dim objMap As MapPoint.Map
Dim objLocMS As MapPoint.Location
Dim objLocHRC As MapPoint.Location

' Uncomment the following line to make MapPoint visible
' objApp.Visible = True

' Get a map object
Set objMap = objApp.NewMap

' Clear the route (
objMap.ActiveRoute.Clear

'Illustrate finding a United States address
Set objLocMS = objMap.FindAddress("One Microsoft Way", "Redmond",
"Washington", "98052", geoCountryUnitedStates)
If objLocMS Is Nothing Then
MsgBox "Sorry - did not find US address"
Exit Sub
End If

' Found it OK - add to route
objMap.ActiveRoute.Waypoints.A dd objLocMS, "Microsoft"

'Illustrate finding a Canadian address
Set objLocHRC = objMap.FindAddress("4295 Blackcombe Way",
"Whistler", "British Columbia", "VON1B4", geoCountryCanada)
If objLocHRC Is Nothing Then
MsgBox "Sorry - did not find Canadian address"
Exit Sub
End If

' Found it OK - add to route
objMap.ActiveRoute.Waypoints.Add objLocHRC, "HRC"

' Compute route
objMap.ActiveRoute.Calculate
If objMap.ActiveRoute.IsCalculated Then
MsgBox "The distance is " & objMap.ActiveRoute.Distance & _
IIf(objApp.Units = geoMiles, " miles", " km")
Else
MsgBox "Sorry, could not compute route"
End If
End Sub

Michael R. Mattys
Mattys MapLib for Microsoft MapPoint
http://www.mattysconsulting.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 

Whatever you Wanadoo:
http://www.wanadoo.co.uk/time/

This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm


More information about the AccessD mailing list