Geoportal Extension for OpenLayers API Reference

Class: Route

ol.control.Route

Route Control.

new Route(options)

OpenLayers/Controls/Route.js, line 104
Name Type Description
options Object

route control options

Name Type Default Description
apiKey String optional

API key for services call (route and autocomplete services). The key "calcul" is used by default.

ssl Boolean true optional

use of ssl or not (default true, service requested using https protocol)

collapsed Boolean true optional

Specify if widget has to be collapsed (true) or not (false) on map loading. Default is true.

draggable Boolean false optional

Specify if widget is draggable

export Boolean | Object false optional

Specify if button "Export" is displayed. For the use of the options of the "Export" control, see ol.control.Export

exclusions Object {"toll" : false, "tunnel" : false, "bridge" : false} optional

list of exclusions with status (true = checked). By default : no exclusions checked.

graphs Array ["Voiture", "Pieton"] optional

list of resources, by default : ["Voiture", "Pieton"]. The first element is selected.

routeOptions Object {} optional

route service options. see Gp.Services.route() to know all route options.

autocompleteOptions Object {} optional

autocomplete service options. see Gp.Services.autoComplete() to know all autocomplete options

markersOpts Object optional

options to use your own markers. Object properties can be "departure", "stages" or "arrival". Corresponding value is an object with following properties :

Name Type Description
url String optional

marker base64 encoded url (ex "data:image/png;base64,...""). Mandatory for a custom marker

offset Array optional

Offsets in pixels used when positioning the overlay. The first element in the array is the horizontal offset. A positive value shifts the overlay right. The second element in the array is the vertical offset. A positive value shifts the overlay down. Default is [0, 0]. (see http://openlayers.org/en/latest/apidoc/ol.Overlay.html)

layerDescription Object {} optional

Layer informations to be displayed in LayerSwitcher widget (only if a LayerSwitcher is also added to the map)

Name Type Default Description
title String "Itinéraire" optional

Layer title to be displayed in LayerSwitcher

description String "Itinéraire basé sur un graphe" optional

Layer description to be displayed in LayerSwitcher

Fires:
  • route:drawstart
  • route:drawend
  • route:compute
  • export:compute
Example
var route = ol.control.Route({
     "collapsed" : true
     "draggable" : true,
     "export"    : false,
     "exclusions" : {
        "toll" : true,
        "bridge" : false,
        "tunnel" : true
     },
     "graphs" : ['Pieton', 'Voiture'],
     "markersOpts" : {
         "departure" : {
             "url" : "...",
             "offset" : [0,0]
         },
         "stages" : {
             "url" : "...",
             "offset" : [0,0]
         },
         "arrival" : {
             "url" : "...",
             "offset" : [0,0]
         }
     }
     "autocompleteOptions" : {},
     "routeOptions" : {}
 });

 // if you want to pluggued the control Export with options :
 var route = new ol.control.Route({
   export : {
     name : "export",
     format : "geojson",
     title : "Exporter",
     menu : false
   }
 });

Extends

  • ol.control.Control

Members

collapsed

{Boolean} specify if Route control is collapsed (true) or not (false)

draggable

{Boolean} specify if Route control is draggable (true) or not (false)

Methods

clean()

OpenLayers/Controls/Route.js, line 468

Clean UI : reinit control

getCollapsed(){Boolean}

OpenLayers/Controls/Route.js, line 206

Returns true if widget is collapsed (minimized), false otherwise

Returns:
- true if widget is collapsed

getContainer(){DOMElement}

OpenLayers/Controls/Route.js, line 360

Get container

getData(){Object}

OpenLayers/Controls/Route.js, line 289

Get route informations

Returns:
- route informations

getGeoJSON(){String}

OpenLayers/Controls/Route.js, line 267

Get vector layer

Returns:
- GeoJSON format layer

getLayer(){Object}

OpenLayers/Controls/Route.js, line 236

Get vector layer where geoJson route is drawn

Returns:
- ol.layer.Vector route layer

getStyle(){ol.style}

OpenLayers/Controls/Route.js, line 369

Get default style

init()

OpenLayers/Controls/Route.js, line 377

This method is public.
It allows to init the control.

setCollapsed(collapsed)

OpenLayers/Controls/Route.js, line 215

Collapse or display widget main container

Name Type Description
collapsed Boolean

True to collapse widget, False to display it

setData(data)

OpenLayers/Controls/Route.js, line 317

Set route data

Name Type Description
data Object

control informations

Name Type Description
transport String

transport type

computation String

computation type

exclusions Array

list of exclusions

points Array

list of points : [[lon, lat]]

results Object

service response

setGeoJSON(geojson)

OpenLayers/Controls/Route.js, line 276

Set vector layer

Name Type Description
geojson String

GeoJSON format layer

setLayer(layer)

OpenLayers/Controls/Route.js, line 245

Set vector layer where route geometry is drawn

Name Type Description
layer Object

ol.layer.Vector route layer

setMap(map)

OpenLayers/Controls/Route.js, line 164

Overwrite OpenLayers setMap method

Name Type Description
map ol.Map

Map.