Constructor
new Map(options)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Map options.
|
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: [76771, 72205]
});
Members
fit experimental
Fit the map to an extent. The default extent is content of a vector layer.
Methods
activateModifyDrawing(enabled)
Draw a polygon on the map.
Parameters:
Name | Type | Description |
---|---|---|
enabled |
boolean |
the callback function. |
addBgSelector(target, bglayers)
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. |
bglayers |
Array.<(string|number)> | undefined |
Array of overlay layer identifiers. 'blank' acts as blank layer. |
- Source:
- See:
addGeoJSON(url, opt_optionsopt) → {Promise}
It displays a GeoJSON file on the map.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string |
Url to the GeoJSON file. |
|||||||||||||||||||||||||||
options |
Options.
|
Returns:
The vector layer promise.
- Type
- Promise
addGeoJSONObject(geojson, opt_optionsopt) → {Promise}
It displays a GeoJSON object on the map. The default data projection is EPSG:4326.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
geojson |
Object |
The GeoJSON object. |
|||||||||||||||||||||||||||
options |
Options.
|
Returns:
The vector layer promise.
- Type
- Promise
addGPX(url, opt_optionsopt) → {Promise}
It displays a GPX file on the map.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string |
Url to the GPX file. |
|||||||||||||||||||||||||||
options |
Options.
|
- Source:
- See:
Returns:
The vector layer promise.
- Type
- Promise
addKML(url, opt_optionsopt)
It displays a KML file on the map.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string |
Url to the KML file. |
|||||||||||||||||||||||||||
options |
Options.
|
- 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
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
Collection
.
Parameters:
Name | Type | Description |
---|---|---|
layer |
string | number |
The layer id. |
opacity |
number | undefined |
The layer opacity. Default is 1. |
visibility |
boolean | undefined |
The layer visibility. Default is true. |
- Source:
- See:
addMyMapLayer(options) → {Promise}
It loads a MyMaps layer.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
The options.
|
- 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, selectFirstopt)
It adds the search control into an html element.
Parameters:
Name | Type | Description |
---|---|---|
target |
Element | string |
Dom element or id of the element to render search widget in. |
dataSets |
Array.<string> (defaults to ['Adresse') |
Array of layer used as search sources. |
onSelect |
function | undefined |
Optional function called when result is selected. |
selectFirst |
boolean | undefined |
Optional True select the first result element on enter. |
- Source:
- See:
createVectorLayer(style) → {VectorLayer}
Create a new empty vector layer.
Parameters:
Name | Type | Description |
---|---|---|
style |
Style | Array.<Style> | ol.StyleFunction | undefined |
The style to apply to the layer. |
Returns:
The created layer.
- Type
- VectorLayer
destroyMap()
Destroy the map.
disableDrawTool()
Disable the current drawing tool.
enableDrawLine(onDrawEnd)
Draw a polygon on the map.
Parameters:
Name | Type | Description |
---|---|---|
onDrawEnd |
function | undefined |
the callback function. |
queryLayer. |
boolean | undefined |
enableDrawPoint(onDrawEnd)
Draw a point on the map.
Parameters:
Name | Type | Description |
---|---|---|
onDrawEnd |
function | undefined |
the callback function. |
enableDrawPolygon(onDrawEnd)
Draw a polygon on the map.
Parameters:
Name | Type | Description |
---|---|---|
onDrawEnd |
function | undefined |
the callback function. |
enableQueryOnClick()
Enable query layer after clicking on the map.
Parameters:
Name | Type | Description |
---|---|---|
queryOnClick. |
boolean |
enableQueryOnDrawEnd()
Enable query layer after finishing to draw on the map.
Parameters:
Name | Type | Description |
---|---|---|
queryOnDrawEnd. |
boolean |
enableShowSelectedFeature(showSelectedFeature)
If set to true, then it allows to display the clicked feature.
Parameters:
Name | Type | Description |
---|---|---|
showSelectedFeature |
boolean |
exportGeoJSON(fArray, opt_optionsopt, exportMeasuresopt) → {string}
Transforms features into geojson
Parameters:
Name | Type | Description |
---|---|---|
fArray |
Array.<ol.Feature> |
features array. |
options |
olx.format.GeoJSONOptions | undefined |
Options. |
exportMeasures |
boolean | undefined |
True if length and area should be added to attributes. |
Returns:
The geojson string.
- Type
- string
getDrawingLayer() → {VectorLayer}
Get the layer containing drawn features.
Returns:
The show layer.
- Type
- VectorLayer
getGeometryArea(geometry, srs) → {number}
Get the area of a geometry in square meters.
Parameters:
Name | Type | Description |
---|---|---|
geometry |
ol.geom.Geometry |
The geometry the get the area. |
srs |
string |
the geometry's srs. Default is EPSG:3857. |
Returns:
The spherical area (in square meters).
- Type
- number
getGeometryLength(geometry, srs) → {number}
Get the length of a geometry in meters.
Parameters:
Name | Type | Description |
---|---|---|
geometry |
ol.geom.Geometry |
The geometry the get the area. |
srs |
string |
the geometry's srs. Default is EPSG:3857. |
Returns:
The spherical length (in meters).
- Type
- number
getMapReadyPromise() → {Promise}
Get the promise to have a map in a ready state.
Returns:
Promise of a configured map.
- Type
- Promise
getPrintSpec()
Get the print spec.
getShowLayer() → {VectorLayer}
Get the layer containing highlighted features.
Returns:
The show layer.
- Type
- VectorLayer
print(nameopt, layoutopt, scaleopt, firstPagesUrlsopt, callbackopt, formatopt)
Prints the current map.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | undefined |
The title of the map. |
layout |
string | undefined |
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 | undefined |
The scale to use. |
firstPagesUrls |
Array.<Object> | undefined |
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'}] |
callback |
function | undefined |
Optional callback function. |
format |
String | undefined |
the output format. Default value is pdf. |
Example
map.print();
removeDrawings()
Remove the drawings.
setCenter(coordinate, zoom, positionSrs)
Set the center of the current view in EPSG:2169.
Parameters:
Name | Type | Description |
---|---|---|
coordinate |
ol.Coordinate |
The coordinate of the center. |
zoom |
number | undefined |
The zoom numer. |
positionSrs |
string | number | undefined |
The projection of the position coordinates.
Default is |
setLanguage(lang)
Parameters:
Name | Type | Description |
---|---|---|
lang |
string |
Set the language. |
setLayerInfoCb(layerInfoCb)
Set the information callback function.
Parameters:
Name | Type | Description |
---|---|---|
layerInfoCb |
function | undefined |
The callback function. |
setPopupTarget(optPopupTarget, optPopupClass)
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 |
optPopupClass |
string | undefined |
The css class of the row. |
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 |
setShowlayerStyle(style)
Parameters:
Name | Type | Description |
---|---|---|
style |
Style | Array.<Style> | ol.StyleFunction | null | undefined |
The style of the show layer. |
showFeatures(layer, ids, opt_clicknullable, opt_target, isShowMarker, maxZoom, callback)
Parameters:
Name | Type | Description |
---|---|---|
layer |
string | number |
The layer identifier |
ids |
Array.<(string|number)> |
Array of features identifiers |
click |
boolean |
True if click is needed to show popup |
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. |
callback |
function | undefined |
Optional callback function called for each id. |
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. |
showMarker(opt_optionsopt) → {Overlay}
Show a marker on the map at the given location.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Config options
|
Returns:
The overlay containing the marker or null if the marker target is not conform.
- Type
- Overlay
showPopup(position, title, content) → {Overlay}
It shows a popup.
Parameters:
Name | Type | Description |
---|---|---|
position |
ol.Coordinate |
The position of the popup. |
title |
string |
The popup title. |
content |
string |
The popup content. |
Returns:
The popup overlay.
- Type
- Overlay