Geoportal Extension for OpenLayers
API Reference

Class: LocationSelector

ol.control.LocationSelector

LocationSelector component. Enables to select a location, using autocompletion or picking location on the map

new LocationSelector(options)

Controls/LocationSelector/LocationSelector.js, line 61
Name Type Description
options Object optional

component options

Name Type Default Description
apiKey String optional

API key for autocomplete service call. The key "calcul" is used by default.

ssl Boolean true optional

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

displayInfo Boolean true optional

whether to display info in a popup or not (not implemented yet) Default is true

tag Object optional

tag options

Name Type Default Description
id Number 1 optional

order id number in a locations group, in case several LocationSelector are used. For instance in route case : departure tag id should be 0, arrival tag id should be 1, and other ones : 2, 3, ...

groupId Number null optional

locationSelector global component id (in case locationSelector is called by another graphic component, e.g. route control)

label String optional

text to display in component (e.g. "Departure"). Default is ">"

markerOpts Object optional

options to use your own marker. Default is a lightOrange marker.

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 ol.Overlay)

display Boolean true optional

whether to display or hide component. Default is true

addOption Boolean false optional

whether to display picto to add another LocationSelector (in case of route control)

removeOption Boolean false optional

whether to display picto to remove a LocationSelector (in case of route control)

autocompleteOptions Object optional

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

Example
var locationselector = new LocationSelector({
     apiKey : "",
     tag : {
        id : 1,
        groupId : null,
        label : "Départ",
        markerOpts : {
             url : "...",
             offset : [0,0]
        },
        display : true
     },
     autocompleteOptions : {}
 });

Extends

  • ol.control.Control

Members

_addPointElement

elements pour ajouter ou supprimer un nouveau point

_buttonLabel

container du label du point

_coordinate

coordonnées du point selectionné, en EPSG:4326

_currentLocation

localisant

_inputAutoComplete

container de la saisi de l'autocompletion

_inputCoordinateContainer

container des coordonnées

_inputsContainer

container principal des entrées

_inputShowPointer

label du pointer de saisi sur la carte (avec img)

_inputShowPointerContainer

container du pointer de saisi sur la carte

_map

container map

_resources

ressources du services d'autocompletion (ayant droit!)

_suggestedContainer

container des reponses de l'autocompletion

_suggestedLocations

listes des reponses de l'autocompletion

_uid

uuid

Methods

_initContainer(){DOMElement}

Controls/LocationSelector/LocationSelector.js, line 272

initialize component container

Returns:
element

clear()

Controls/LocationSelector/LocationSelector.js, line 245

clean all and input

clearResults()

Controls/LocationSelector/LocationSelector.js, line 253

clear all results and the marker.

getCoordinate(){Array}

Controls/LocationSelector/LocationSelector.js, line 215

get coordinate

Returns:
- point coordinate (EPSG:4326) : [lon, lat]

initialize(options)

Controls/LocationSelector/LocationSelector.js, line 103

initialize component

Name Type Description
options Object

options

onLocationAddPointClick(e)

Controls/LocationSelector/LocationSelector.js, line 507

TODO this method is called by event 'click' on 'GProuteStageAdd' tag input
(cf. this._createRouteAddPointElement).
this point is added as a parameter for the service route.

Name Type Description
e Object

HTMLElement

setCoordinate(coordinate, crs)

Controls/LocationSelector/LocationSelector.js, line 224

set coordinate

Name Type Description
coordinate Object

Coordinate in the map projection by default, otherwise, the projection is entered in the following parameter

crs String

Coordinate projection