Class: Map

lux.Map

The map is the core component of the Geoportail V3 API. This constructor instantiates and render a lux.Map object.

Constructor

new Map(options)

Parameters:
Name Type Description
options luxx.MapOptions

Map options.

Properties
Name Type Description
callback function | undefined

Function called when the objects are initialized.

bgLayer string | undefined

Identifier of background layer. Default to basemap_2015_global.

bgSelector luxx.BgSelectorOptions | undefined

Set the presence of a background selector control in the map. (not included by default).

controls ol.Collection.<ol.control.Control> | Array.<ol.control.Control> | undefined

Controls initially added to the map. If not specified, ol.control.defaults() is used.

features luxx.FeaturesOptions | undefined

Set the presence of features to recenter on & to show markers for. (not included by default).

layerManager luxx.LayerManagerOptions | undefined

Set the presence of a layer manager control. (not included by default)

layerOpacities Array.<number> | undefined

Array of opacities for the layers.

layerVisibilities Array.<boolean> | undefined

Array of visibilities for the layers.

layers Array.<(string|number)> | undefined

Array of overlay layer identifiers.

mousePosition luxx.MousePositionOptions | undefined

Set the presence of a mouse position control in the map. (not included by default).

popupTarget Element | string | undefined

The container for map popups, either the element itself or the id of the element.

position ol.Coordinate | undefined

The initial position of the center for the map view. The coordinate system for the center is specified with the positionSrs option. If a center is defined in the view, then this parameter will override the center defined in the view.

positionSrs string | number | undefined

The projection of the position coordinates. Default is 2169.

queryableLayers Array.<(string|number)> | undefined

Array of queryable layers.

search luxx.SearchOption | undefined

The search configuration.

showLayerInfoPopup boolean | undefined

If set to true, it displays the feature information in a popup or in popupTarget element.

target Element | string

The container for the map, either the element itself or the id of the element. Required.

view ol.View | undefined

The map's view.

zoom number | undefined

Zoom level used to calculate the initial resolution for the view. If zoom are defined here and in the view, this parameter will override the view one.

Source:
Example
// To render a map, the API needs to know the element where to display the map (target),
// the predefined background layer (bgLayer) to display,
// the predefined layers (layers),
// the starting zoom level (zoom),
// the central position of the map (position)
var map = new lux.Map({
target: 'map1',
bgLayer: 'basemap_2015_global',
zoom: 18,
position: [75977, 75099]
});

Extends

Methods

addBgSelector(target)

It adds a simple background selector control into a specific html element.

Parameters:
Name Type Description
target Element | string

Dom element or id of the element to render bgSelector in.

Source:
See:

addGeoJSON(url, opt_optionsopt)

It displays a GeoJSON file on the map.

Parameters:
Name Type Attributes Description
url string

Url to the GeoJSON file.

opt_options luxx.VectorOptions <optional>

Options.

Properties
Name Type Description
reloadInterval number | undefined

Interval after which to reload the vector layer (in seconds).

style ol.StyleFunction | undefined

The style function.

name string | undefined

The layer name.

click boolean | undefined

If set, the popup is displayed when clicking the feature.

target Element | string | undefined

The container for the feature popup, either the element itself or the id of the element.

Source:

addGPX(url, opt_optionsopt)

It displays a GPX file on the map.

Parameters:
Name Type Attributes Description
url string

Url to the GPX file.

opt_options luxx.VectorOptions <optional>

Options.

Properties
Name Type Description
reloadInterval number | undefined

Interval after which to reload the vector layer (in seconds).

style ol.StyleFunction | undefined

The style function.

name string | undefined

The layer name.

click boolean | undefined

If set, the popup is displayed when clicking the feature.

target Element | string | undefined

The container for the feature popup, either the element itself or the id of the element.

Source:
See:

addKML(url, opt_optionsopt)

It displays a KML file on the map.

Parameters:
Name Type Attributes Description
url string

Url to the KML file.

opt_options luxx.VectorOptions <optional>

Options.

Properties
Name Type Description
reloadInterval number | undefined

Interval after which to reload the vector layer (in seconds).

style ol.StyleFunction | undefined

The style function.

name string | undefined

The layer name.

click boolean | undefined

If set, the popup is displayed when clicking the feature.

target Element | string | undefined

The container for the feature popup, either the element itself or the id of the element.

Source:
See:

addLayer(layer)

Adds the given layer to the top of this map. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on ol.Collection.

Parameters:
Name Type Description
layer ol.layer.Base

Layer.

Source:
See:

addLayerById(layer, opt_opacityopt, opt_visibilityopt)

Adds the given layer to the top of this map. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on ol.Collection.

Parameters:
Name Type Attributes Description
layer string | number

The layer id.

opt_opacity number <optional>

The layer opacity. Default is 1.

opt_visibility boolean <optional>

The layer visibility. Default is true.

Source:
See:

addMyMapLayer(options) → {Promise}

It loads a MyMaps layer.

Parameters:
Name Type Description
options luxx.MyMapOptions

The options.

Properties
Name Type Description
mapId string

The map identifier. Required.

profileTarget string | undefined

The id of the element in which to put the profile (without #). Optional. It is recommended to set the display style to none at first. The display will then be set to block adequately.

onload function | undefined

The function called once the map is loaded. Optional.

Source:
See:
Returns:

Promise of the mymaps object.

Type
Promise
Example
var map8 = new lux.Map({
target: 'map8',
bgLayer: 'topo_bw_jpeg',
zoom: 12,
position: [76825, 75133]
});
map8.addMyMapLayer({
 mapId: '0416ef680fbe4cdaa2d8009262d1127c'
});

addSearch(target, dataSetsopt, onSelectopt)

It adds the search control into an html element.

Parameters:
Name Type Attributes Default Description
target Element | string

Dom element or id of the element to render search widget in.

dataSets Array.<string> <optional>
['Adresse'

Array of layer used as search sources.

onSelect function <optional>

Optional function called when result is selected.

Source:
See:

getShowLayer() → {ol.layer.Vector}

Get the layer containing highlighted features.

Source:
Returns:

The show layer.

Type
ol.layer.Vector

print(nameopt, layoutopt, scaleopt, firstPagesUrlsopt)

Prints the current map.

Parameters:
Name Type Attributes Description
name string <optional>

The title of the map.

layout string <optional>

The layout of the map. Default is A4 landscape or A4 portrait depending on the map size. Available values are : A4 landscape, A4 portrait, A3 landscape, A3 portrait, A2 landscape, A2 portrait, A1 landscape, A1 portrait, A0 landscape, A0 portrait

scale number <optional>

The scale to use.

firstPagesUrls Array.<Object> <optional>

An array containing urls and type of pages that will be introduced at the beginning of the pdf. Only html and pdf are supported. [{'url': 'http://url1', 'html'},{'url': 'http://url2' 'pdf'}]

Source:
Example
map.print();

setLanguage(lang)

Parameters:
Name Type Description
lang string

Set the language.

Source:

setPopupTarget(optPopupTarget)

Sets the popup target or undefined to let the api create popup.

Parameters:
Name Type Description
optPopupTarget Element | string | undefined

The container for map popups, either the element itself or the id of the element. Undefined lets the popup be created by the api.

Source:

setQueryableLayers(queryableLayers)

Set the queryable layers. If undefined then use the default value from metadata.

Parameters:
Name Type Description
queryableLayers Array.<(string|number)> | undefined

An array of queryable layers

Source:

showFeatures(layer, ids, opt_clicknullable, opt_target, isShowMarker, maxZoom)

Parameters:
Name Type Attributes Description
layer string | number

The layer identifier

ids Array.<(string|number)>

Array of features identifiers

opt_click boolean <nullable>

True if click is needed to show popup

opt_target Element | string | undefined

Element to render popup content in

isShowMarker boolean | undefined

True if a marker has to be displayed.

maxZoom number | undefined

The maximum zoom to fit.

Source:

showLayerInfoPopup(show)

Show a marker on the map at the given location.

Parameters:
Name Type Description
show boolean

Set to true will allow to display the feature information popup when clicking on an object.

Source:

showMarker(opt_optionsopt) → {ol.Overlay}

Show a marker on the map at the given location.

Parameters:
Name Type Attributes Description
opt_options luxx.MarkerOptions <optional>

Config options

Properties
Name Type Description
noPopupOnTransparency boolean | undefined

Allow to deactivate popup when clicking on a transparent part of the marker. This property is experimental. The marker should come from the same source as the page, or the image server has to set the following header Access-Control-Allow-Origin "*"

position ol.Coordinate | undefined

Position of the marker. If not set, the marker is displayed at the center of the map.

positionSrs string | number | undefined

The projection of the position coordinates. Default is 2169.

autoCenter boolean | undefined

Tells whether the map should be recentered to the marker position.

iconURL string | undefined

URL to an image. Defaults to //openlayers.org/en/master/examples/data/icon.png.

positioning string | undefined

Positioning of the icon. See //openlayers.org/en/latest/apidoc/ol.html#.OverlayPositioning

html string | undefined

If set, HTML code or simple text that will be displayed when clicking on the marker.

click boolean | undefined

If set, the popup is displayed when clicking the marker.

target Element | string

The container for the marker popup, either the element itself or the id of the element. Required.

Source:
Returns:

The overlay containing the marker or null if the marker target is not conform.

Type
ol.Overlay