cgxp.plugins.Routing

ptype
cgxp_routing
class cgxp.plugins.Routing(config)

Example Use

Sample code showing how to add a Routing plugin to a gxp.Viewer in a existing container:

new gxp.Viewer({
    ...
    tools: [{
        ptype: 'cgxp_routing',
        outputTarget: "left-panel",
        osrmURL: "${request.route_url('osrmproxy')}",
        searchURL: "${request.route_url('ftsproxy')}",
        outputConfig: {
            labelAlign: 'top',
            defaults: {
                anchor: '100%'
            },
            autoFit: true
        }
    }]
    ...
});

Sample code showing how to add a Routing plugin to a gxp.Viewer via an icon in a toolbar. The routing form will show up in a CGXP.tool.Window below the toolbar:

new gxp.Viewer({
    ...
    tools: [{
        ptype: 'cgxp_routing',
        actionTarget: "center.tbar",
        toggleGroup: "maptools",
        osrmURL: "${request.route_url('osrmproxy')}",
        searchURL: "${request.route_url('ftsproxy')}",
        outputConfig: {
            labelAlign: 'top',
            defaults: {
                anchor: '100%'
            },
            autoFit: true
        }
    }]
    ...
});

Config Options

Configuration properties.

actionTarget

Object or String or Array Where to place the tool’s actions (e.g. buttons or menus)? As opposed to CGXP.plugins.Tool, we don’t want it to be set by default to the mapPanel top toolbar.

directionsTpl

XTemplate used to format driving directions. There are four specific formatters added to Ext.util.Format for routing:

  • Ext.util.Format.routeImage - creates an img tag with an image from directionType. Invoke with {directionType:routeImage}
  • Ext.util.Format.routeDistance - formats the distance as m or km with variable decimal places depending on distance. Invoke with {distance:routeDistance}
  • Ext.util.Format.routeTime - formats the time as “h m s” appropriately. Invoke with {time:routeTime}
  • Ext.util.Format.routeDirection - formats a translated version of the driving directions for a given directionType. This formatter expects to be passed the entire record and should be invoked using {[Ext.util.Format.routeDirection(values)]} to work correctly.
limits

Object Option object to configure search limit parameters sent to the text search service. The possible properties are:

  • limit - Number The maximum number of results in the response.
  • partitionlimit - Number The maximum number of results per layer/group in the response.

partitionlimit is typically used when the grouping option is to true, to limit the number of results in each group.

If the limits option is unspecified the limit parameters sent in search requests depend whether grouping is true or false:

  • If grouping is false then limit is set to 20, and partitionlimit is not set.
  • If grouping is true then limit is set to 40, and partitionlimit is set to 10.

Any provided limits object is applied to the default values. For example, if grouping is true and if the limits option is set to {limit: 50} then limit will be set to 50 and partitionlimit will be set to 10 in search requests.

outputConfig

String Panel config options.

routingService

Object Object which controls the routing service to be used. Keys identify the routing engine to use, ENGINE_0 is for computing the fastest route by car. The key will be localised using OpenLayers.i18n and the value will be used in the Method field of the routing panel. The value of each key contains the following options:

  • type - String Type of the routing service, currently only OSRM is supported.
  • url - String Base URL of the routing service
  • dynamic - Boolean If true, update the route dynamically as points on the route are moved

Additional properties are available depending on the type of the routing service.

OSRM-specific Properties:

none.

searchOptions

String Options for a FullTextSearch widget.

timeout

Number The timeout delay for fetching results from full text search and routing engines in milliseconds. Default to 2 minutes.

vectorLayerConfig

Object Optional configuration of the vector layer.

Table Of Contents

Previous topic

cgxp.plugins.Redlining

Next topic

cgxp.plugins.ScaleChooser

This Page

Fork me on GitHub