I am trying to write some code which mimicks the b....

Anonymous
11-24-2001, 03:22 PM
I am trying to write some code which mimicks the behaviour of clicking on a direction line in a calculated route, i.e. the map is zoomed to show a good view of this road segment in green, the turn is highlighted blue, a pushpin is placed at the turn location with the pop-up text being the turn instruction.

I have tried the following code:
Dim oMap As MapPoint.Map
Dim oRte As MapPoint.Route
Set oMap = GetObject(, "MapPoint.Application").ActiveMap
Set oRte = oMap.ActiveRoute

oRte.Waypoints.Add oMap.FindAddressResults(, "London", , ) (1)
oRte.Waypoints.Add oMap.FindAddressResults(, "Birmingham", , ) (1)
oRte.Calculate

Dim i As Integer
Dim loc As MapPoint.Location
For i = 1 to oRte.Directions.Count
loc := oRte.Directions.Item[i].Location
loc.GoTo
loc.Highlight = true
MsgBox "Here is a turn"
Next i

This runs, but the behaviour is not as expected. The locations returned display larger sections of the route, and is centered on what seems an arbitary point, there is no highlighting, and no pushpin.

Can anyone help with reproducing this behaviour.

Thanks Brian

Anonymous
11-24-2001, 03:22 PM
Try "oRte.Directions(i).Select".

For example:

Sub Test()
Dim oMap As MapPoint.Map
Dim oRte As MapPoint.Route
Set oMap = GetObject(, "MapPoint.Application").ActiveMap
Set oRte = oMap.ActiveRoute
oRte.Waypoints.Add oMap.FindResults("Seattle, Washington")(1)
oRte.Waypoints.Add oMap.FindResults("Tacoma, Washington")(1)
oRte.Calculate

oRte.Directions(2).Location.GoTo
oRte.Directions(2).Select

End Sub

 
Web mp2kmag.com
mapforums.com