Class: Profile

ol.control. Profile

OpenLayers 3 Profile Control. Draw a profile of a feature (with a 3D geometry)


new Profile( [options])

Parameters:
Name Type Argument Description
options Object <optional>
Properties
Name Type Argument Default Description
className string
title String

button title

style ol.style.Style <optional>

style to draw the profile, default darkblue

selectStyle ol.style.Style <optional>

style for selection, default darkblue fill

info *

keys/values for i19n

width number <optional>
300
height number <optional>
150
units 'metric' | 'imperial' <optional>
'metric'

output system of measurement Note that input z coords are expected to be in meters in either mode (as determined by GPX, DEM, DSM, etc. standards).

feature ol.Feature <optional>

the feature to draw profile

selectable boolean <optional>
false

enable selection on the profil, default false

zoomable boolean <optional>
false

can zoom in the profile

numberFormat string <optional>

Convert numbers to a custom locale format, default is not used

Author:
  • Gastón Zalba https://github.com/GastonZalba
  • Jean-Marc Viglino https://github.com/viglino
Fires:
  • event:over
  • event:out
  • event:show
  • event:dragstart
  • event:dragging
  • event:dragend
  • event:dragcancel

Extends

Members


info

Custom infos list

Methods


_numberFormat(number, decimals,)

Convert numbers to a custom locale format. Enables language-sensitive number formatting using locales with browser native method toLocaleString. This is useful to change the decimal separator as well as to add/change the thousands separator.

Parameters:
Name Type Description
number number | string
decimals, number

default is 2

Returns:
Type
string

_unitsConversion(nMeters, targetUnit)

Convert meters to another system of measurement or unit

Parameters:
Name Type Description
nMeters number
targetUnit 'm' | 'km' | 'ft' | 'mi'

default is m

Returns:
Type
number

getImage(type, encoderOptions)

Get profile image

Parameters:
Name Type Description
type string | undefined

image format or 'canvas' to get the canvas image, default image/png.

encoderOptions Number | undefined

between 0 and 1 indicating image quality image/jpeg or image/webp, default 0.92.

Returns:

requested data uri

Type
string

getSelection(starting, ending)

Get selection

Parameters:
Name Type Description
starting number

point

ending number

point

Returns:
Type
Array.<ol.coordinate>

hide()

Hide panel


isShown()

Is panel visible


onMove()

Mouse move over canvas


pointAtTime(time)

Get the point at a given time on the profile

Parameters:
Name Type Description
time number

time at which to show the point

Returns:

current point

Type
ol.coordinates

Show popup info

Parameters:
Name Type Description
info string

to display as a popup


refresh()

Refresh the profile


setGeometry(f [, options])

Set the geometry to draw the profile.

Parameters:
Name Type Argument Description
f ol.Feature | ol.geom.Geometry

the feature.

options Object <optional>
Properties
Name Type Argument Default Description
projection ol.ProjectionLike <optional>

feature projection, default projection of the map

zunit 'm' | 'km' | 'ft' | 'mi' <optional>
'm'

'm', 'km', 'ft' or 'mi', default 'm' or 'ft' according to the System of measurement

unit 'm' | 'km' | 'ft' | 'mi' <optional>
'km'

'm', 'km', 'ft' or 'mi', default 'km' or 'mi' according to the System of measurement

zmin Number | undefined <optional>
0

default 0

zmax Number | undefined <optional>

default max Z of the feature

zDigits integer | undefined <optional>
0

number of digits for z graduation, default is calculated according to the value range

xDigits integer | undefined <optional>
1

number of digits for x-axis (distance), default 1

zDigitsHover number <optional>
2

Decimals number while hovering the profile graph, default 2

xDigitsHover number <optional>
1

Decimals number while hovering the profile graph, default 1

zMaxChars integer | undefined <optional>

maximum number of chars to be used for z graduation before switching to scientific notation

graduation Number | undefined <optional>
100

length of each z graduation step, default 100. If zSteps is provided, this is not used

amplitude integer | undefined <optional>

amplitude of the altitude, default zmax-zmin

xSteps integer | undefined <optional>

number of steps at the x-axis (distance), default 10. If not provided, default is calculated from the distance

zSteps integer | undefined <optional>

number of steps at the amplitude scale. If not provided, default is calculated from graduation


show()

Show panel


showAt(where)

Show point at coordinate or a distance on the profile

Parameters:
Name Type Description
where ol.coordinates | number

a coordinate or a distance from begining, if none it will hide the point

Returns:

current point

Type
ol.coordinates

showAtTime(time, delta)

Show point at a time on the profile

Parameters:
Name Type Description
time Date | number

a Date or a DateTime (in s) to show the profile on, if none it will hide the point

delta booelan

true if time is a delta from the start, default false

Returns:

current point

Type
ol.coordinates

toggle()

Toggle panel