Geoportal Extension for OpenLayers API Reference

Class: GeoportalMousePosition

ol.control.GeoportalMousePosition

MousePosition Control.

new GeoportalMousePosition(options)

OpenLayers/Controls/MousePosition.js, line 119
Name Type Description
options Object

options for function call.

Name Type Default Description
apiKey String optional

API key. The key "calcul" is used by default.

ssl Boolean true optional

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

draggable Boolean false optional

Specify if widget is draggable

collapsed Boolean true optional

Specify if MousePosition control should be collapsed at startup. Default is true.

units Array optional

list of coordinates units, to be displayed in control units list.
Values may be "DEC" (decimal degrees), "DMS" (sexagecimal), "RAD" (radians) and "GON" (grades) for geographical coordinates,
and "M" or "KM" for metric coordinates

displayAltitude Boolean true optional

activate (true) or deactivate (false) the altitude panel. True by default

displayCoordinates Boolean true optional

activate (true) or deactivate (false) the coordinates panel. True by default

editCoordinates Boolean false optional

If true, coordinates from the MousePosition control can be edited by users to re-center the view. False by default.

mapCenterCallback function optional

callback...

systems Array optional

list of projection systems, default are Geographical ("EPSG:4326"), Web Mercator ("EPSG:3857"), Lambert 93 ("EPSG:2154") and extended Lambert 2 ("EPSG:27572").
Each array element (=system) is an object with following properties :

Name Type Description
crs String

Proj4 crs alias (from proj4 defs). e.g. : "EPSG:4326". Required

label String optional

CRS label to be displayed in control. Default is crs code (e.g. "EPSG:4326")

type String

CRS units type for coordinates conversion : "Geographical" or "Metric". Default: "Metric"

geoBBox Object optional

Aera covered by the system (WGS84 coordinates).

Name Type Description
right Number

Right bound.

left Number

Left bound.

top Number

Top bound.

bottom Number

Bottom bound.

positionMarker Object optional

options for position marker

Name Type Description
url String

Marker url (define in src/Openlayers/Controls/Utils/Markers.js)

offset Array

Offsets in pixels used when positioning the marker towards targeted point.
The first element in the array is the horizontal offset. A positive value shifts the marker right.
The second element in the array is the vertical offset. A positive value shifts the marker down. [0,0] value positions the top-left corner of the marker image to the targeted point.
Default is offset associated to default marker image.

hide Boolean

if true, marker is not displayed, otherwise displayed (False by default.)

altitude Object optional

elevation configuration

Name Type Description
serviceOptions Object optional

options of elevation service

responseDelay Number optional

latency for altitude request, 500 ms by default

triggerDelay Number optional

immobilisation time of movement on the map to trigger the elevation calculation, 200 ms by default

noDataValue Number optional

value used for altitude service no data (default is -99999). In this case, "---m" will be displayed instead of "-99999m"

noDataValueTolerance Number optional

tolerance for no data value :
values in [noDataValue + noDataValueTolerance ; noDataValue - noDataValueTolerance] interval will not be displayed, but "---m" will be displayed instead.
Default is 90000 (no data values = [-9999 ; -189999])

Example
var MousePosition = new ol.control.GeoportalMousePosition({
     "collapsed" : false,
     "graggable" : true,
     "displayCoordinates" : true,
     "displayAltitude" : true,
     "altitude" : {
          "triggerDelay" : 100,
          "responseDelay" : 500,
          "noDataValue" : -99999,
          "noDataValueTolerance" : 99000,
          "serviceOptions" : {}
     },
     "systems" : [
      {
         "crs" : "EPSG:3857",
         "label" : "Web Mercator",
         "type" : "Metric"
      },
      {
         "crs" : "EPSG:4326",
         "label" : "Géographiques",
         "type" : "Geographical"
      },
      {
          "label" : "Lambert 93",
          "crs" : "EPSG:2154",
          "type" : "Metric",
          "geoBBox" : {
              "left" : -9.86,
              "bottom" : 41.15,
              "right" : 10.38,
              "top" : 51.56
          }
       }
     ],
     "units" : ["DEC", "DMS"]
});

Extends

  • ol.control.Control

Members

collapsed

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

draggable

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

Methods

addSystem(system)

OpenLayers/Controls/MousePosition.js, line 268

Set additional projection system

Name Type Description
system Object

projection system

Name Type Description
crs String

Proj4 crs alias (from proj4 defs) e.g. "EPSG:4326"

label String optional

CRS label to be displayed in control. Default is system.crs alias

type String optional

CRS units type for coordinates conversion (one of control options.units). Default is "Metric"

addSystems(systems)

OpenLayers/Controls/MousePosition.js, line 324

Set additional projection systems

Name Type Description
systems Array

Array of system object, with following properties :

Name Type Description
crs String

Proj4 CRS alias (from proj4 defs) e.g. "EPSG:4326"

label String

CRS label (for coordinates conversion)

type String

CRS units type to be displayed in control (one of control options.units). Default is "Metric"

displayAltitude(displayAltitude)

OpenLayers/Controls/MousePosition.js, line 444

Display or hide elevation panel

Name Type Description
displayAltitude Boolean

true to display elevation panel, false to hide it

displayCoordinates(displayCoordinates)

OpenLayers/Controls/MousePosition.js, line 458

Display or hide coordinates panel

Name Type Description
displayCoordinates Boolean

true to display coordinates panel, false to hide it

onMousePositionEditModeClick(editing)

OpenLayers/Controls/MousePosition.js, line 1387

this method is called by event 'click' on input coordinate

Name Type Description
editing Boolean

editing mode

removeSystem(systemCrs)

OpenLayers/Controls/MousePosition.js, line 342

Remove projection system (in case there are several system with same code, only the first one will be removed)

Name Type Description
systemCrs String

CRS alias (from proj4 defs)

setAltitudeOptions(options)

OpenLayers/Controls/MousePosition.js, line 424

Set control altitude options (useless if displayAltitude == false)

Name Type Description
options Object

altitude options

Name Type Description
serviceOptions Object optional

options of elevation service

responseDelay Number optional

latency for elevation request, 500 ms by default

triggerDelay Number optional

immobilisation time of movement on the map to trigger the elevation calculation, 200 ms by default

setCollapsed(collapsed)

OpenLayers/Controls/MousePosition.js, line 472

Collapse or display control main container

Name Type Description
collapsed Boolean

True to collapse control, False to display it

setMap(map)

OpenLayers/Controls/MousePosition.js, line 178

Overload ol.control.Control setMap method, called when

Name Type Description
map Object

the map

setUnits(units)

OpenLayers/Controls/MousePosition.js, line 404

Set control units (to be displayed)

Name Type Description
units Array

list of all coordinates units, to be displayed in control units list.
Values may be "DEC" (decimal degrees), "DMS" (sexagecimal), "RAD" (radians) and "GON" (grades) for geographical coordinates,
and "M" or "KM" for metric coordinates