-
Name Type Description options
Map Options
Name Type Description target
string HTML element ID map container. Mandatory field.
bounds
module:cercaliagl/Bounds~Bounds Initial map bounding box. Default:
null
.center
module:cercaliagl/LonLat~LonLat Center map coordinates. Default values
x=-2.530985346701069
,y=40.14298996438731
controls
Array.<string> Map controls to include. Values:
srcArrow
string Arrow to be used when feature has showDirections = true
disableKeyboardControls
boolean Disable controls to move/rotate/pan map with the keyboard = true
drawStyles
Array.<module:cercaliagl/MapStyler~StyleLayerJSON> Draw styles. Default
[]
.adaptDrawStylesToFeatureStyle
boolean Adapt draw styles to feature style. Default
false
.cercaliagl.control.MapControls.SCALELINE
cercaliagl.control.MapControls.CLEAN
cercaliagl.control.MapControls.GAS_STATIONS
cercaliagl.control.MapControls.LAYER_SWITCHER
cercaliagl.control.MapControls.METEO
cercaliagl.control.MapControls.NAVBAR
cercaliagl.control.MapControls.TRAFFIC
cercaliagl.control.MapControls.ZOOM
cercaliagl.control.MapControls.ISOCHRONES
If you want a map without controls put value `[]`.
mapLayers
Array.<string> Default map base layers.
cercalia.MapTypes.CERCALIA
,cercalia.MapTypes.OSM
, `cercalia.MapTypes.SATELLITE``.customBaseLayers
Array.<(module:cercaliagl/layer/XYZ~XYZ|module:cercaliagl/layer/WMS~WMS)> Custom base layers
zoom
number Initial zoom level
[0 - 19]
. Default value6
minZoom
number Minimum zoom. Default value
2
maxZoom
number Maximum zoom. Default value
19
cooperativeGestures
boolean Setting cooperativeGesturs to true, scroll to zoom requires command key, and two fingers to pan the map on mobile version.
restrictedBounds
module:cercaliagl/Bounds~Bounds Bounding box limits for map navigation. Default
null
.rotation
number Map bearing in degrees. Default value
0
defaultClick
function Assign function to click on map. Function parameters: (1->pixel, 2->
cercalia.LonLat
).- Pixel where clicked with mouse right click.
- Map coordinate.
defaultBaseLayer
string Default base layer. Default
cercalia
.lang
string Language, you must put useBrowserLanguage to false. Default
en
.useBrowserLanguage
boolean Enable/Disable the usage by default of the browser language. Default
true
.geolocationEnabled
boolean Enable automatically geolocation. Your position will be drawn to map.
rightClickMenu
boolean Enable/Disable menu on mouse right click. Default
true
.rightClickFunction
function Assign function to mouse right click. For apply this option it's necessary to disable contextmenu on map initialization with option (
rightClickMenu:false
).
The function parameters are: (1->pixel, 2->cercalia.LonLat
).- Pixel where clicked with mouse right click.
- Map coordinate.
Default: `null`.
rightClickMenuOptions
Array.<string> Map rightClick menu options to include. Values:
cercalia.ContextMenu.Option.ADDRESS
cercalia.ContextMenu.Option.ROUTING
cercalia.ContextMenu.Option.DISTANCE
If you want a map without rightClick menu options put value [].
Default `[cercalia.ContextMenuOptions.Location, cercalia.ContextMenuOptions.Routing]`.
multipleFeaturesInPixel
boolean Return multiple features in same pixel, for mouse events. Default
true
.pitch
number Map pitch. Default value
0
onRotationEnd
function Function is called when the rotation of the map changes (called at the event's end).
onMoveEnd
function Function is called when map is moved (called at the event's end).
onZoomEnd
function Function is called when the zoom of the map changes (called at the event's end).
onPitchEnd
function Function is called when the pitch of the map changes (called at the event's end).
antialias
boolean Antialias for GL render. Default
false
.themeColor
string Theme color
routing3d
routing3d Draw 3D polyline for calculated route feature. Default
false
.freehandOnDrawPolygonMobile
boolean Draw polygon button on mobile will active freehand mode. Default
false
.
Methods
-
Name Type Description marker
Marker Marker that will be animated
feature
Feature Feature (type linestring) where marker will be animated
speed
number Speed of marker
numSteps
number Number of steps to divide the marker path
-
Name Type Description feature
module:cercaliagl/Feature~Feature Feature
layer
module:cercaliagl/layer/Feature~Feature Feature layer
callbackFn
function callback function when finished
-
Name Type Description baseLayer
module:cercaliagl/layer/XYZ~XYZ | module:cercaliagl/layer/WMS~WMS Base layer
mapType
string | undefined Map type
-
Add custom control. You can specify children position inside control container. Default append to last child.
Name Type Description control
module:cercaliagl/control/Custom~Custom Custom control.
position
number Position.
-
Name Type Description feature
module:cercaliagl/Feature~Feature Feature
layer
module:cercaliagl/layer/Feature~Feature Feature layer
updateGeoJSON
boolean (defaults to true) Update GeoJSON after add feature, true by default
-
Name Type Description features
Array.<module:cercaliagl/Feature~Feature> Features
layer
module:cercaliagl/layer/Feature~Feature Feature layer
-
Name Type Description id
string id
label
string label
baseLayers
Array.<(module:cercaliagl/layer/XYZ~XYZ|module:cercaliagl/layer/WMS~WMS)> Base layers
mapType
string | undefined Map type
-
Add layer
Name Type Description layer
module:cercaliagl/layer/Base~LayerLike Layer
beforeLayerId
string Before layer id. Only when base layer is MVT type.
-
Name Type Description marker
module:cercaliagl/Marker~Marker Marker
layer
module:cercaliagl/layer/Marker~Marker -
Name Type Description marker
Array.<module:cercaliagl/Marker~Marker> Marker
layer
module:cercaliagl/layer/Marker~Marker Layer
-
Center on current GPS position
-
Name Type Description features
Array.<module:cercaliagl/Feature~Feature> Features
options
Options
Name Type Description animation
boolean Animation.
duration
number Duration if animation is enabled. Default
2000
.changeZoom
boolean Change zoom
zoom
number zoom to change
-
Name Type Description markers
Array.<module:cercaliagl/Marker~Marker> Markers
options
Options
Name Type Description animation
boolean Animation.
duration
number Duration if animation is enabled. Default
2000
.changeZoom
boolean Change zoom
zoom
number zoom to change
-
Available layers.
cercaliagl.MapTypes.CERCALIA
cercaliagl.MapTypes.SATELLITE
cercaliagl.MapTypes.OSM
cercaliagl.MapTypes.DARK
cercaliagl.MapTypes.SILVER
cercaliagl.MapTypes.BLANKMAP
cercaliagl.MapTypes.GOOGLE_STYLE
cercaliagl.MapTypes.EMPTY
Name Type Description baseLayer
string Base layer
-
Close all menus and reset nav bar menu view.
-
Close all open popups
Name Type Description layer
module:cercaliagl/layer/Marker~Marker | undefined -
Returns the pixel value from a coordinate
Name Type Description lonLat
module:cercaliagl/LonLat~LonLat Coordinate.
Returns:
Return pixel of map.
-
Disable marker clustering. Only available for
module:cercaliagl/layer/Marker~Marker
layer.Name Type Description layerId
string Layer id. Default
LayersId.MARKERS_LAYER_ID
. -
Disable draw interaction
-
Name Type Description layerId
string Layer id. Default
LayersId.MARKERS_LAYER_ID
. -
Enable marker clustering. Only available for
module:cercaliagl/layer/Marker~Marker
layer.Name Type Description options
Clustering options
Name Type Description layerId
string Layer id. Default
LayersId.MARKERS_LAYER_ID
.onClick
function Click over callback function.
onMouseOver
function Mouse over callback function.
onMouseOut
function Mouse out callback function.
maxZoom
number Max zoom for clustering. Default
16
.radius
number Radius in pixels to cluster. Default
40
. -
Enable draw interaction
Name Type Description type
string Available values
line|polygon|draw_magnetic_polygon|circle|freehand_polygon
options
Draw options
Name Type Description onDrawEnd
function Callback function when feature has been drawn. It receive geometry drawn
-
Converts layer into heatmap. There are two layers: Zone layer for heat, and points layer. Points layers is useful to show markers in the nearest zooms. For better adaptation customize layer styles. Depends of number and density you should adjust heat layer styles. Read MapboxGL documentation to styling both layers: https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#heatmap.
Default values for styles for zones if
options.styleHeatZones
property is not provided:{ maxzoom: 15, paint: { 'heatmap-intensity': [ 'interpolate', ['linear'], ['zoom'], 0, 0.1, 15, 1.5, ], 'heatmap-color': [ 'interpolate', ['linear'], ['heatmap-density'], 0, 'rgba(0, 0, 255, 0)', 0.1, 'royalblue', 0.3, 'cyan', 0.5, 'lime', 0.7, 'yellow', 1, 'red', ], 'heatmap-radius': [ 'interpolate', ['linear'], ['zoom'], 0, 1, 15, 14, ], 'heatmap-opacity': [ 'interpolate', ['linear'], ['zoom'], 7, 0.8, 15, 0.3, ], }, }
Default values for styles for points if
options.styleHeatPoints
property is not provided:{ minzoom: 14, paint: { 'circle-radius': [ 'interpolate', ['linear'], ['zoom'], 12, 3, 16, 6, ], 'circle-color': 'rgba(0,0,0,0.4)', 'circle-stroke-color': 'white', 'circle-stroke-width': 1, }, }
Name Type Description options
Heatmap layer options
Name Type Description layerId
string Layer id. Default
LayersId.MARKERS_LAYER_ID
.styleHeatZones
module:cercaliagl/layer/Marker~StyleHeatLayer Style layer zone. Read MapboxGL documentation https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#heatmap.
styleHeatPoints
module:cercaliagl/layer/Marker~StyleHeatLayer Point layer zone. Use layer
type: circle
styles. https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle -
Export PNG image
Name Type Description filename
string (defaults to ExportCercaliaMap.png) Filename.
-
Get map center
Returns:
Map center
-
Returns the container ID
Returns:
id Map container Id
-
Get context menu. Useful if user wants to add or remove
Returns:
Context menu
-
Name Type Description name
string Name
-
Get marker by ID. It returns null if it is not found.
Name Type Description id
string Id.
layer
module:cercaliagl/layer/Feature~Feature Marker layer.
Returns:
marker Marker ornull
if not found.
-
Name Type Description layer
module:cercaliagl/layer/Feature~Feature -
Returns:
Geolocation
-
Returns:
Language
-
Get layer by id
Name Type Description layerId
string Layer id
-
Returns:
Map routing object
-
Returns:
Map routing object
-
Get marker by ID. It returns null if it is not found.
Name Type Description id
string Id.
layer
module:cercaliagl/layer/Marker~Marker Marker layer.
Returns:
marker Marker ornull
if not found.
-
Name Type Description layer
module:cercaliagl/layer/Marker~Marker -
Returns:
Rotation in degrees.
-
Return width & height container div in pixels
Returns:
Size in pixels
-
Returns:
Current zoom level of map.
-
Hide all map controls
-
hide all marker labels
Name Type Description layer
module:cercaliagl/layer/Marker~Marker | undefined -
-
Name Type Description eventName
string Event name
callbackFn
function Callback function
-
Name Type Description eventName
string Event name
callbackFn
function Callback function
-
Open the context menu at the coordinates specified by parameters. If not specified, opens the context menu in the map center according to the current position.
Name Type Description lonLat
module:cercaliagl/LonLat~LonLat Coordinate
-
Show all markers popups. Only for markers with popup created
-
Moves the map to the new center
Name Type Description position
module:cercaliagl/LonLat~LonLat Coordinates.
animation
boolean (defaults to true) Enable or disable animation. Default
true
. -
Map center maintaining the zoom level
Name Type Description bounds
module:cercaliagl/Bounds~Bounds Mapbounds.
animation
boolean Enable or disable animation. Default
true
. -
Calculate the real distance in meters, from pixels values.
Name Type Description pixels
number Pixels to measure
Returns:
meters Return measure in meters.
-
Returns the coordinate from a pixel value
Name Type Description pixel
module:cercaliagl/pixel~Pixel pixel of map.
Returns:
Coordinate
-
Name Type Description layer
module:cercaliagl/layer/Feature~Feature Feature layer
-
Name Type Description layer
module:cercaliagl/layer/Marker~Marker -
Name Type Description feature
module:cercaliagl/Feature~Feature Feature
layer
module:cercaliagl/layer/Feature~Feature Feature layer
-
Name Type Description feature
module:cercaliagl/Feature~Feature Feature
layer
module:cercaliagl/layer/Feature~Feature Feature layer
-
Remove layer
Name Type Description layer
module:cercaliagl/layer/Base~LayerLike Layer
-
Name Type Description marker
module:cercaliagl/Marker~Marker Marker
layer
module:cercaliagl/layer/Marker~Marker Layer
-
Name Type Description markers
Array.<module:cercaliagl/Marker~Marker> layer
module:cercaliagl/layer/Marker~Marker -
Rotates the map
degrees, by parameter Name Type Description angle
number Angle (degrees).
animation
boolean (defaults to true) Animation. Default
true
. -
Set the map center
Name Type Description lonLat
module:cercaliagl/LonLat~LonLat Coordinates
zoom
number Zoom
animation
boolean (defaults to false) Enable or disable animation. Default
true
.speed
number (defaults to 1) Speed animation. Default 1.
-
Name Type Description contextMenu
module:cercaliagl/ContextMenu~ContextMenu Context menu
-
Set default click function. When map is clicked parameter function is triggered.
Name Type Description func
function | undefined Function
-
Name Type Description lang
string Language
-
Name Type Description pitch
number Pitch
animation
boolean (defaults to true) Animation. Default
true
. -
Sets the map rotation
Name Type Description bearing
number Angle in degrees.
animation
boolean (defaults to true) Animation. Default
true
. -
Set the zoom level of map. If second parameter is specified (boolean, optional)
Name Type Description zoom
number Zoom level to adjust
-
Show 3D buildings in close zooms.
Name Type Description visible
boolean Visible or not.
showToBuildings
boolean (defaults to false) Buildings
-
Show map controls
-
Name Type Description infoMap
module:cercaliagl/InfoMap~InfoMap Info map.
-
show all marker labels
Name Type Description layer
module:cercaliagl/layer/Marker~Marker | undefined -
Toggle full screen, only available inside any button event.
-
Force a recalculation of the map viewport size. This should be called when map container changes its size