Geoportal Extension for OpenLayers
API Reference

Class: ElevationPath

ol.control.ElevationPath

Elevation Path Control. Allows users to draw a path on a Openlayers map see the elevation profile computed with geoportal elevation path web service along that path.

new ElevationPath(options)

Controls/ElevationPath/ElevationPath.js, line 114
Name Type Description
options Object

options for function call.

Name Type Default Description
apiKey String optional

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

active Boolean false optional

specify if control should be actived at startup. Default is false.

ssl Boolean true optional

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

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

elevationOptions Object {} optional

elevation path service options. See Gp.Services.getAltitude() for available options

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 "Profil altimétrique" optional

Layer title to be displayed in LayerSwitcher

description String "Mon profil altimétrique" optional

Layer description to be displayed in LayerSwitcher

stylesOptions Object optional

styles management

Name Type Default Description
marker Object {} optional

styles management of marker displayed on map when the user follows the elevation path. Specified with an ol.style.Image subclass object

draw Object {} optional

styles used when drawing. Specified with following properties.

Name Type Default Description
pointer Object {} optional

Style for mouse pointer when drawing the line. Specified with an ol.style.Image subclass object.

start Object {} optional

Line Style when drawing. Specified with an ol.style.Stroke object.

finish Object {} optional

Line Style when finished drawing. Specified with an ol.style.Stroke object.

displayProfileOptions Object {} optional

profile options.

Name Type Default Description
totalDistance Boolean true optional

display the total distance of the path

greaterSlope Boolean true optional

display the greater slope into the graph

meanSlope Boolean true optional

display the mean slope into the graph

ascendingElevation Boolean true optional

display the ascending elevation into the graph

descendingElevation Boolean true optional

display the descending elevation into the graph

currentSlope Boolean true optional

display current slope value on profile mouseover

apply function optional

function to display profile if you want to cutomise it. By default, (DISPLAY_PROFILE_BY_DEFAULT()) is used. Helper functions to use with D3 (DISPLAY_PROFILE_LIB_D3()) or AmCharts (DISPLAY_PROFILE_LIB_AMCHARTS()) frameworks are also provided. You may also provide your own function.

target Object optional

DOM container to use to display the profile.

Fires:
  • elevationpath:drawstart
  • elevationpath:drawend
  • elevationpath:compute
  • export:compute
Example
var measure = new ol.control.ElevationPath({
   export : false,
   stylesOptions : {
    draw : {
      finish : new ol.style.Stroke({
           color : "rgba(0, 0, 0, 0.5)",
           width : 2
      })
    },
   }
   displayProfileOptions : {
      apply : ol.control.ElevationPath.DISPLAY_PROFILE_RAW,
   }
});

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

Exemples :
- displayProfileOptions.apply : null
- displayProfileOptions.apply : function (elevations, container, context) {  // do some stuff... }
- displayProfileOptions.apply : ol.control.ElevationPath.DISPLAY_PROFILE_{LIB_AMCHARTS | LIB_D3 | RAW}

Extends

  • ol.control.Control

Members

DEFAULT_STYLES

Styles applied by default if stylesOptions property is not set.

Methods

staticDISPLAY_PROFILE_BY_DEFAULT(data, container, context)

Controls/ElevationPath/ElevationPath.js, line 496

Display Profile function used by default : no additonal framework needed.

Name Type Description
data Object

elevations values for profile

container HTMLElement

html container where to display profile

context Object

this control object

staticDISPLAY_PROFILE_LIB_AMCHARTS(data, container, context)

Controls/ElevationPath/ElevationPath.js, line 433

display Profile using Amcharts framework. This method needs AmCharts libraries to be loaded.

Name Type Description
data Object

collection elevations

container HTMLElement

container

context Object

this control object

staticDISPLAY_PROFILE_LIB_D3(data, container, context)

Controls/ElevationPath/ElevationPath.js, line 456

display Profile using D3 javascript framework. This method needs D3 libraries to be loaded.

Name Type Description
data Object

elevations values for profile

container HTMLElement

html container where to display profile

context Object

this control object

staticDISPLAY_PROFILE_RAW(data, container, context)

Controls/ElevationPath/ElevationPath.js, line 479

display Profile without graphical rendering (raw service response)

Name Type Description
data Object

elevations values for profile

container HTMLElement

html container where to display profile

context Object

this control object

clean(remove)

Controls/ElevationPath/ElevationPath.js, line 710

clean

Name Type Description
remove Boolean

remove layer

getActive(){Boolean}

Controls/ElevationPath/ElevationPath.js, line 571

Returns true if widget is actived (drawing),
false otherwise

Returns:
- true or false

getContainer(){DOMElement}

Controls/ElevationPath/ElevationPath.js, line 640

Get container

getData(){Object}

Controls/ElevationPath/ElevationPath.js, line 606

Get elevation data

Returns:
- elevations
Example
{
       type // "elevationpath"
       greaterSlope // pente max
       meanSlope  // pente moyenne
       distancePlus // distance cumulée positive
       distanceMinus // distance cumulée négative
       ascendingElevation // dénivelé cumulée positive
       descendingElevation // dénivelé cumulée négative
       altMin // altitude min
       altMax // altitude max
       distance // distance totale
       unit // unité des mesures de distance
       points // elevations
  }

getGeoJSON(){String}

Controls/ElevationPath/ElevationPath.js, line 681

Get vector layer

Returns:
- GeoJSON format layer

getLayer(){ol.layer.Vector}

Controls/ElevationPath/ElevationPath.js, line 649

Get layer

getStyle(){ol.style}

Controls/ElevationPath/ElevationPath.js, line 702

Get default style

init()

Controls/ElevationPath/ElevationPath.js, line 734

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

setActive(active)

Controls/ElevationPath/ElevationPath.js, line 581

Actived widget drawing or not

Name Type Description
active Boolean

true / false

setData(data)

Controls/ElevationPath/ElevationPath.js, line 631

Set profile data

Name Type Description
data *

elevations

Example
{
       greaterSlope // pente max
       meanSlope  // pente moyenne
       distancePlus // distance cumulée positive
       distanceMinus // distance cumulée négative
       ascendingElevation // dénivelé cumulée positive
       descendingElevation // dénivelé cumulée négative
       altMin // altitude min
       altMax // altitude max
       distance // distance totale
       unit // unité des mesures de distance
       points // elevations
}

setLayer(layer)

Controls/ElevationPath/ElevationPath.js, line 658

Set layer

Name Type Description
layer Object

ol.layer.Vector profil layer

setMap(map)

Controls/ElevationPath/ElevationPath.js, line 515

Attach control to map. Overloaded ol.control.Control.setMap() method.

Name Type Description
map ol.Map

Map.