A versatile and lightweight toolkit for building a simple web map.
This project is maintained by qqnluaq
Add a button to the toolbar, that shows a panel that allows the user to pick locations on the map, and calculate the fastest (or shortest) route between them.
This tool interacts with the "identify"
tool and "location"
tool.
When this tool is enabled, the popups for identify and location will contain a button to start a route from that location.
This is default configuration for the Layers tool (click on a property name for more information):
{ "tools": [ { "type": "directions", "title": "Route Planner", "showTitle": false, "enabled": false, "icon": "directions_car", "order": 4, "position": [ "shortcut-emnu", "list-menu", "toolbar" ], "command": { "optimal": true, "roundTrip": true, "criteria": true, "vehicleType": true, "truckRoute": true, "truckHeight": true, "truckWidth": true, "truckLength": true, "truckWeight": true, }, "truck": false, "optimal": false, "roundTrip": false, "criteria": "shortest", "truckRoute": null, "truckHeight": null, "truckWidth": null, "truckLength": null, "truckWeight": null, "geocoderService": { "url": "https://geocoder.api.gov.bc.ca/", "timeout": 10000, "parameter": {} } "routePlannerService": { "url": "https://router.api.gov.bc.ca/", "apiKey": null } } ] }
"type"
: String
(Required)
The name of the type of this tool. Identifies the tool in the configuration, this is required.
Must be one of these values:
"about"
,
"basemaps"
,
"bespoke"
,
"coordinate"
,
"directions"
,
"identify"
,
"layers"
,
"legend"
,
"list-menu"
,
"location"
,
"markup"
,
"measure"
,
"minimap"
,
"pan"
,
"query"
,
"scale"
,
"search"
,
"select"
,
"shortcut-menu"
,
"toolbar"
,
"version"
,
or
"zoom"
.
"title"
: String
The title of this tool. Tools that display a panel will use this as the title of the panel. The toolbar button for this tool will use this as the tooltip. Tools have a default title, and setting this property will override the default title with one of the author’s choosing.
"showTitle"
: Boolean
If true
, then the title of the tool is shown beside the button in the toolbar.
Defaults to false
.
"enabled"
: Boolean
If true
then the tool will be available when the map starts.
If false
, then the tool will not be available.
"icon"
: String
If the tool adds a button to a toolbar, this property gives the name of the icon to display on the button. The icon set used is the Material Design Icons.
"order"
: Integer
If the tool adds a button to a toolbar, this property controls the order in which the tools are added to the toolbar.
The default value is 1
, but some tools have other values as their default.
The tools are added left-to-right in ascending order.
"position"
: String
Some tools show a button that activates the tool, and that button must be positioned in one of the tool button containers.
The tool button containers are: toolbar
, list-menu
, and shortcut-menu
.
This property’s value is the name of the container, or null
to prevent button from appearing.
The tool button container must itself be enabled.
"command"
: Object
Determines which controls are visible on the panels for this tool.
"command"
: { "optimal": Boolean }
If true
, shows the Optimal control in the directions tool options.
"command"
: { "roundTrip": Boolean }
If true
, shows the Round Trip control in the directions tool options.
"command"
: { "criteria": Boolean }
If true
, shows the Criteria control in the directions tool options.
"command"
: { "vehicleType": Boolean }
If true
, shows the Vehicle Type control in the directions tool options.
"command"
: { "truckRoute": Boolean }
If true
, shows the Truck Route control in the directions tool options.
"command"
: { "truckHeight": Boolean }
If true
, shows the Truck Height control in the directions tool options.
"command"
: { "truckWidth": Boolean }
If true
, shows the Truck Width control in the directions tool options.
"command"
: { "truckLength": Boolean }
If true
, shows the Truck Length control in the directions tool options.
"command"
: { "truckWeight": Boolean }
If true
, shows the Truck Weight control in the directions tool options.
"truck"
: Boolean
If true
, the route planner generates a route specifically for a truck, otherwise the route is for any vehicle.
"optimal"
: Boolean
If true
, the route planner will optimize the order of waypoints to find the shortest route, otherwise the waypoints are taken in the order presented.
"roundTrip"
: Boolean
If true
, the route planner will generate a route that visits all waypoints, and then returns to the first one. Otherwise, the route will start at the first waypoint, and end at the last waypoint.
"criteria"
: String
The value can be "fastest"
or "shortest"
, and the route planner will try to find the best route according to that constraint.
See Route Planner Docs.
"truckRoute"
: Number
Truck route multiplier. See Route Planner Docs.
"truckHeight"
: Number
Height of truck in meters.
"truckWidth"
: Number
Width of truck in meters.
"truckLength"
: Number
Length of truck in meters.
"truckWeight"
: Number
Weight of truck in kilograms.
"geocoderService"
: Object
The configuration object used to connect to the BC Geocoder Service. The default configuration object is:
{
"url": "https://geocoder.api.gov.bc.ca/",
"timeout": 10000,
"parameter": {}
}
Typically an application will need a specific form of geocoder request, and so will need to provide a "parameters"
object.
"routePlannerService"
: Object
The configuration object used to connect to the BC Route Planner. The default configuration object is:
{
"url": "https://router.api.gov.bc.ca/",
"apiKey": null
}
The application developer will need to acquire and provide a value for the "apiKey"
in order to use this service.
See the Route Planner documentation for details.