1.1 What is it?
Microsoft® MapPoint® 2009 gives you the power to visualize business data, communicate insights with instant impact, and integrate maps into the work you do in Microsoft Office.
A trial version can be obtained at MapPoint North America & MapPoint Europe
This Dynamics NAV code (based on NAV W1 5.0 SP1) adds a menu "MapPoint" to the Customer card, with the items
- Show address on map
- Show route on map
- Get driving directions
Show address on map: the location of the customer is pointed on a map (that is if the location can be found).
Show route on map: the route is calculated between the address of company CRONUS (table Company Information) and the customer.
Get driving directions: the driving directions for the route between the address of company CRONUS (table Company Information) and the customer is displayed (line by line) in NAV.
Additionally, the menu "MapPoint" is also added to the Customer List form, with the items:
- Show route on map
- Show route on map (optimized)
- Get optimized route order
- Get driving directions
Show route on map: the route is calculated between the addresses that are selected. If only one address is selected, the route is calculated as on the Customer card form.
Show route on map (optimized): the optimized route is calculated between the addresses that are selected. If only one address is selected, the route is calculated as on the Customer card form.
Get optimized route order: the optimized order in which the selected customers should be visited, is displayed in NAV.
...
Get driving directions: same functionality as on Customer card.
Note: MapPoint 2009 Europe was used for developing and testing.
1.2 Installation
Name | DataType | Subtype | ||
autMapPointAppl | Automation | 'Microsoft MapPoint 16.0 Object Library (Europe)'.Application | ||
autMapPointMap | Automation | 'Microsoft MapPoint 16.0 Object Library (Europe)'.Map | ||
autMapPointLocation | Automation | 'Microsoft MapPoint 16.0 Object Library (Europe)'.Location | ||
autMapPointFindResults | Automation | 'Microsoft MapPoint 16.0 Object Library (Europe)'.FindResults | ||
autMapPointRoute | Automation | 'Microsoft MapPoint 16.0 Object Library (Europe)'.Route | ||
autMapPointDirection | Automation | 'Microsoft MapPoint 16.0 Object Library (Europe)'.Direction |
1.3 How to use the automation code in your Dynamics NAV code
The MapPoint Automation codeunit consists of the following functions:
- fctInit
- fctAddPushpin
- fctShow
- fctCalcRoute
- fctReturnCountryCode
- fctSetOptimizeRoute
- fctGetNumberOfWaypoints
- fctGetRouteOrder
- fctGetNumberOfDirections
- fctGetDrivingDirections
- fctClose
To display the location of a customer, you need following code:
cduMapPoint.fctInit;
cduMapPoint.fctAddPushpin(Address,City,'',County,"Post Code","Country Code",Name,
STRSUBSTNO('Customer %1',"No."),FALSE);
cduMapPoint.fctShow;
To calculate the route to a customer, you need following code:
cduMapPoint.fctInit;
cduMapPoint.fctCalcRoute(Address,City,'',County,"Post Code","Country Code",Name,
STRSUBSTNO('Customer %1',"No."));
cduMapPoint.fctShow;
This will calculate the route from the address found in Company Information, to the address of
the customer.
If you want to calculate the route to different customers at once, you need following code:
IF recCust.FIND('-') THEN BEGIN
cduMapPoint.fctInit;
REPEAT
cduMapPoint.fctAddPushpin(recCust.Address,recCust.City,'',recCust.County,recCust."Post Code",recCust."Country Code",
recCust.Name,STRSUBSTNO('Customer %1',recCust."No."),TRUE);
UNTIL recCust.NEXT = 0;
cduMapPoint.fctShow;
END;
If you want to calculate the optimized route to different customers at once, you need following code:
IF recCust.FIND('-') THEN BEGIN
cduMapPoint.fctInit;
REPEAT
cduMapPoint.fctAddPushpin(recCust.Address,recCust.City,'',recCust.County,recCust."Post Code",recCust."Country Code",
recCust.Name,STRSUBSTNO('Customer %1',recCust."No."),TRUE);
UNTIL recCust.NEXT = 0;
cduMapPoint.fctSetOptimizeRoute;
cduMapPoint.fctShow;
END;
If you want to retrieve the optimized route order, you need following code:
IF recCust.FIND('-') THEN BEGIN
cduMapPoint.fctInit;
REPEAT
cduMapPoint.fctAddPushpin(recCust.Address,recCust.City,'',recCust.County,recCust."Post Code",recCust."Country Code",
recCust.Name,STRSUBSTNO('Customer %1',recCust."No."),TRUE);
UNTIL recCust.NEXT = 0;
cduMapPoint.fctSetOptimizeRoute;
intTotalNumberOfWaypoints := cduMapPoint.fctGetNumberOfWaypoints;
FOR i := 1 TO intTotalNumberOfWaypoints DO
MESSAGE('Stop %1: %2',i,cduMapPoint.fctGetRouteOrder(i));
cduMapPoint.fctClose;
END;
If you want to retrieve the driving directions, you need following code:
IF recCust.FIND('-') THEN BEGIN
cduMapPoint.fctInit;
REPEAT
cduMapPoint.fctAddPushpin(recCust.Address,recCust.City,'',recCust.County,recCust."Post Code",recCust."Country Code",
recCust.Name,STRSUBSTNO('Customer %1',recCust."No."),TRUE);
UNTIL recCust.NEXT = 0;
cduMapPoint.fctSetOptimizeRoute;
intTotalNumberOfDirections := cduMapPoint.fctGetNumberOfDirections;
FOR i := 1 TO intTotalNumberOfDirections DO
MESSAGE(cduMapPoint.fctGetDrivingDirections(i));
cduMapPoint.fctClose;END;
END;
The function fctReturnCountryCode is used to return the integer that MapPoint internally uses to
designate a country. You will need to modify this function if you use other country-codes.
The Documentation-trigger of codeunit 50002 contains a list of all available
geoCountry-values.
1.4 History
02/03/2009 | Release 3.0 Adds support for MapPoint 2009 Add a way to calculate optimized route between multiple addresses Add a way to retrieve the optimized route, without displaying map Add a way to retrieve the driving directions, without displaying map |
22/08/2005 | Release 2.1 Add a way to calculate route between multiple addresses |
04/08/2005 | Release 2.0 Adds support for MapPoint 2004 |
18/04/2003 | Initial release 1.0 |
1.5 Contact information
If you want to report any bugs or changes, please be free to write me at luc@vandyck.net or leave a note in the mibuso.com forum on http://www.mibuso.com/forum/viewtopic.php?f=7&t=1791.
Regards
Luc Van Dyck