MapView.PlanRoute
-----------------

Plans a route.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MapView](component_MapView.md) | [9.2](newinversion92.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "MapView.PlanRoute"; MapView; SourceAddress; DestinationAddress; Mode { ; TransportType; StartIdentifier; EndIdentifier; StartColor; EndColor } ) 

**MBS**( **"MapView.PlanRoute";** /\* Plans a route. \*/  
**$MapView**; /\* The map view reference number.e.g. $$MapView \*/   
**$SourceAddress**; /\* The address where to start.e.g. "Köln" \*/   
**$DestinationAddress**; /\* The address where to end.e.g. "München" \*/   
**$Mode**; /\* Various options.  
Add 1 to show route on map.  
Add 2 to show alternative routes on the map.  
Add 4 to show start of route with a pin.  
Add 8 to show end of route with a pin.  
Add 16 to zoom map to show whole of the router.  
Add 32 to return result as JSON.  
Add 64 to include poly lines in JSON.e.g. 1+4+8+16 \*/   
**$TransportType**; /\* Optional; The type of transportation to use.  
Value can be a combination of 1 for car, 2 for walk.  
Default is by car.e.g. 1 \*/   
**$StartIdentifier**; /\* Optional; The identifier for the pin to use with script trigger.  
If empty, the plugin assigns a number automatically. \*/   
**$EndIdentifier**; /\* Optional; The identifier for the pin to use with script trigger.  
If empty, the plugin assigns a number automatically. \*/   
**$StartColor**; /\* Optional; The color to use.   
Can be a color name or hex notation like in HTML.e.g. "#FF0000" \*/   
**$EndColor**) /\* Optional; The color to use.   
Can be a color name or hex notation like in HTML.e.g. "#FF0000" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MapView | The map view reference number. | $$MapView |  |
| SourceAddress | The address where to start. | "Köln" |  |
| DestinationAddress | The address where to end. | "München" |  |
| Mode | Various options.   Add 1 to show route on map.   Add 2 to show alternative routes on the map.   Add 4 to show start of route with a pin.   Add 8 to show end of route with a pin.   Add 16 to zoom map to show whole of the router.   Add 32 to return result as JSON.   Add 64 to include poly lines in JSON. | 1+4+8+16 |  |
| TransportType | The type of transportation to use.   Value can be a combination of 1 for car, 2 for walk.   Default is by car. | 1 | Optional |
| StartIdentifier | The identifier for the pin to use with script trigger.   If empty, the plugin assigns a number automatically. |  | Optional      Added in version **9.3**. |
| EndIdentifier | The identifier for the pin to use with script trigger.   If empty, the plugin assigns a number automatically. |  | Optional      Added in version **9.3**. |
| StartColor | The color to use.    Can be a color name or hex notation like in HTML. | "#FF0000" | Optional      Added in version **9.3**. |
| EndColor | The color to use.    Can be a color name or hex notation like in HTML. | "#FF0000" | Optional      Added in version **9.3**. |

### Result

Returns result or error.

### Description

Plans a route.  
The plugin will lookup coordinates for the given addresses and request a route calculation.  
Then we may add show routes and optionally return JSON with results.  
  
You can call this method several times to show multiple routes together.  
### Examples

Plan a route and store JSON:

 Set Variable \[ $r ; Value: MBS ("MapView.PlanRoute"; $$MapView ; "Köln"; "München"; 1+2+4+8+16+32; 1+2+4) \]   
Set Field \[ MapView::Route ; $r \]  
Plan route with coordinates:

 MBS ("MapView.PlanRoute"; $$MapView ;   
"50.938056N 6.956944E"; // Cologne, Germany  
"48.137222N 11.575556E"; // Munich, Germany  
1+4+8+16; 1)  
### Release notes

- **Version 14.4**
    - Improved [MapView.PlanRoute](https://www.mbsplugins.eu/MapViewPlanRoute.shtml) function to use less memory.
- **Version 9.3**
    - Added identifier and color parameters for [MapView.AddPin](http://www.mbsplugins.eu/MapViewAddPin.shtml), [MapView.AddPinWithAddress](http://www.mbsplugins.eu/MapViewAddPinWithAddress.shtml), [MapView.PlanRoute](http://www.mbsplugins.eu/MapViewPlanRoute.shtml) and [MapView.ShowAddress](http://www.mbsplugins.eu/MapViewShowAddress.shtml) functions.
- **Version 9.2**
    - Added [MapView.FormatDistance](http://www.mbsplugins.eu/MapViewFormatDistance.shtml), [MapView.ParseDistance](http://www.mbsplugins.eu/MapViewParseDistance.shtml) and [MapView.PlanRoute](http://www.mbsplugins.eu/MapViewPlanRoute.shtml) functions.

### Example Databases

- [Mac and iOS/MapKit/MapView BeeExample](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapView%20BeeExample.shtml#5ScriptAnchor_)
- [Mac and iOS/MapKit/MapView](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapView.shtml#11ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.4pr1](https://www.mbsplugins.de/archive/2024-07-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 20 - MapView](https://www.mbsplugins.de/archive/2023-12-20/MBS_Plugin_Advent_calendar_20_/monkeybreadsoftware_blog_filemaker)
- [Was gibt es neues bei MBS Version 9.2](https://www.mbsplugins.de/archive/2019-07-16/Was_gibt_es_neues_bei_MBS_Vers/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.3pr2](https://www.mbsplugins.de/archive/2019-06-12/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [More on MapViews in FileMaker](https://www.mbsplugins.de/archive/2019-06-07/More_on_MapViews_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.2pr1](https://www.mbsplugins.de/archive/2019-04-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [Adding route planing for MapView in FileMaker](https://www.mbsplugins.de/archive/2019-03-17/Adding_route_planing_for_MapVi/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2022, Seite 32](https://filemaker-magazin.de/neuigkeit/4174-Appetithappen-FMM_202202)

This function is free to use.

Created 17th March 2019 , last changed 22nd March 2023

  
[MapView.ParseDistance](MapViewParseDistance.md) - [MapView.PointForCoordinate](MapViewPointForCoordinate.md)

[HTML Version](MapViewPlanRoute.shtml)