Listing 1: Adding a pushpin

oleobject loo_Location, loo_Found, loo_PinOffice

loo_Location=ioo_Map.FindAddressResults(&
"Haldenstrasse 65","Zurich","","","8045",&
"Switzerland")
IF loo_Location.ResultsQuality=1 THEN
loo_Found=loo_Location.Item(1)
loo_PinOffice=ioo_Map.AddPushpin(loo_Found,&"Office")
ELSEIF loo_Location.Count > 0 THEN
// Open a Window and let the user choose the location
ELSE
// Not Found
END IF

Listing 2: Calculate route

oleobject loo_PinMainStation, loo_Route, &
loo_WayPoints, loo_Directions, loo_DirEntry
string ls_DirInfo
integer li_Counter

// Get the MainStation PushPin:
// Code is similar to Listing 1, except the pushpin
// is called loo_PinMainStation
loo_Location=ioo_Map.FindAddressResults(&
"Bahnhofplatz”,"Zurich","","","8000",&
"Switzerland")
...
// Get the route object and clear it
loo_Route=ioo_Map.ActiveRoute
loo_Route.Clear()

// Get waypoint object and add puspins
loo_WayPoints=loo_Route.WayPoints
loo_WayPoints.Add(loo_PinOffice)
loo_WayPoints.Add(loo_PinMainStation)

// Calculate the route
loo_Route.Calculate()

// Get Direction
loo_Directions=loo_Route.Directions
FOR li_Counter=1 TO loo_Directions.Count
loo_DirEntry=loo_Directions.Item(li_Counter)
ls_DirInfo=ls_DirInfo + &
loo_DirEntry.Instruction + "~r~n"
NEXT

// Show Information with distance and directions
MessageBox( "Distance: " + &
String(loo_Route.Distance ), ls_DirInfo)

Listing 3: Adding your own dataset

oleobject loo_Tour

// Create your own set
loo_Tour=ioo_Map.DataSets.AddPushPinSet("MyTour")

// Move pushpins to the MyTour datasets
loo_PinOffice.MoveTo(loo_Tour)
loo_PinMainStation.MoveTo(loo_Tour)

… // Change all symbols at one
loo_Tour.Symbol=25

Listing 4: Handling the beforeclick event

Oleobject loo_Item, loo_Clicked, loo_Parent
long ll_Results, ll_Counter, ll_PushPins

// Get the objects located at the mouse pointer
// ocx_x and ocx_y are argument of the event

loo_Clicked =ioo_Map.ObjectsFromPoint( ocx_x, ocx_y )
ll_Results= loo_Clicked.Count

FOR ll_Counter=1 TO ll_Results
loo_Item = loo_Clicked.Item( ll_Counter )
loo_Parent = loo_Item.Parent
// Check if Parent is the Map
IF loo_Parent.Name <> ioo_Map.Name THEN
ll_PushPins ++
END IF
NEXT

// Based on the button clicked
CHOOSE CASE button
CASE 1 // Left
IF ll_PushPins=1 THEN // One found
// Show MessageBox with some information
ELSEIF ll_PushPins>1 THEN
MessageBox("Map","Select 1 Pushpin only")
END IF
Cancel = True // Prevent Default behavior
CASE 2 // Right
m_pin.PopMenu( 0, 0 )
Cancel = True // Prevent Default behavior
CASE ELSE
RETURN // Allow Default behavior
END CHOOSE

Listing 5: Connecting to MapPoint through OLE

// Instance Variables
OleObject ioo_App, ioo_Map

// In the constructor event
ioo_App = CREATE OleObject
ioo_App.ConnectToNewObject("MapPoint.Application")
ioo_App.ActiveMap

// In the destructor event
ioo_App.DisconnectObject()

Listing 6: Calculating the route with OLE Automation

TRY
loo_Route.Calculate()
CATCH (OLERuntimeError err)
MessageBox( "Error", "One address might be"+&
"located in a pedestrian area", StopSign! )
END TRY