-
Name Type Description optionsMap Options
Name Type Description targetstring HTML element ID map container. Mandatory field.
boundsmodule:cercaliagl/Bounds~Bounds Initial map bounding box. Default:
null.centermodule:cercaliagl/LonLat~LonLat Center map coordinates. Default values
x=-2.530985346701069,y=40.14298996438731controlsArray.<string> Map controls to include. Values:
cercaliagl.control.MapControls.SCALELINEcercaliagl.control.MapControls.CLEANcercaliagl.control.MapControls.GAS_STATIONScercaliagl.control.MapControls.LAYER_SWITCHERcercaliagl.control.MapControls.METEOcercaliagl.control.MapControls.NAVBARcercaliagl.control.MapControls.MOBILEBARcercaliagl.control.MapControls.TRAFFICcercaliagl.control.MapControls.ZOOMcercaliagl.control.MapControls.LOGISTICS_RESTRICTIONScercaliagl.control.MapControls.LAYER_REGIONScercaliagl.control.MapControls.ISOCHRONEScercaliagl.control.MapControls.LOGOcercaliagl.control.MapControls.BUILDINGS3Dcercaliagl.control.MapControls.DRAWcercaliagl.control.MapControls.ZBE
If you want a map without controls put value `[]`.
srcArrowstring Arrow to be used when feature has showDirections = true
disableKeyboardControlsboolean Disable controls to move/rotate/pan map with the keyboard = true
drawStylesArray.<module:cercaliagl/MapStyler~StyleLayerJSON> Draw styles. Default
[].adaptDrawStylesToFeatureStyleboolean Adapt draw styles to feature style. Default
false.mapLayersArray.<string> Default map base layers.
cercalia.MapTypes.CERCALIA,cercalia.MapTypes.OSM, `cercalia.MapTypes.SATELLITE``.customBaseLayersArray.<module:cercaliagl/layer/XYZ~XYZ> | Array.<module:cercaliagl/layer/WMS~WMS> Custom base layers
zoomnumber Initial zoom level
[0 - 19]. Default value6minZoomnumber Minimum zoom. Default value
2maxZoomnumber Maximum zoom. Default value
19tollInfoTypemodule:cercaliagl/service/Routing~TollInfoType Format of the toll information displayed when calculating a route. Default value
basic.tollCurrencystring Currency of the toll information displayed when calculating a route. Default value
undefined.routingNetstring Custom routing net. Default value
undefined.cooperativeGesturesboolean Setting cooperativeGesturs to true, scroll to zoom requires command key, and two fingers to pan the map on mobile version.
restrictedBoundsmodule:cercaliagl/Bounds~Bounds Bounding box limits for map navigation. Default
null.rotationnumber Map bearing in degrees. Default value
0defaultClickfunction Assign function to click on map. Function parameters: (1->pixel, 2->
cercalia.LonLat).- Pixel where clicked with mouse right click.
- Map coordinate.
defaultBaseLayerstring Default base layer. Default
cercalia.langstring Language, you must put useBrowserLanguage to false. Default
en.useBrowserLanguageboolean Enable/Disable the usage by default of the browser language. Default
true.geolocationEnabledboolean Enable automatically geolocation. Your position will be drawn to map.
rightClickMenuboolean Enable/Disable menu on mouse right click. Default
true.rightClickFunctionfunction 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`.
rightClickMenuOptionsArray.<string> Map rightClick menu options to include. Values:
cercalia.ContextMenu.Option.ADDRESScercalia.ContextMenu.Option.ROUTINGcercalia.ContextMenu.Option.DISTANCE
If you want a map without rightClick menu options put value [].
Default `[cercalia.ContextMenuOptions.Location, cercalia.ContextMenuOptions.Routing]`.
multipleFeaturesInPixelboolean Return multiple features in same pixel, for mouse events. Default
true.pitchnumber Map pitch. Default value
0onRotationEndfunction Function is called when the rotation of the map changes (called at the event's end).
onMoveEndfunction Function is called when map is moved (called at the event's end).
onZoomEndfunction Function is called when the zoom of the map changes (called at the event's end).
onPitchEndfunction Function is called when the pitch of the map changes (called at the event's end).
antialiasboolean Antialias for GL render. Default
false.themeColorstring Theme color
routing3dboolean Draw 3D polyline for calculated route feature. Default
false.freehandOnDrawPolygonMobileboolean Draw polygon button on mobile will active freehand mode. Default
false.interactiveboolean Disable the map interactions. Default
false.scaleUnitsmodule:maplibre-gl~Unit Units used on the scale and on the measurements results. Default
metric. Values: 'imperial', 'metric' or 'nautical'.
Methods
-
Name Type Description markermodule:cercaliagl/Marker~Marker Marker that will be animated
featuremodule:cercaliagl/Feature~Feature Feature (type linestring) where marker will be animated
speednumber Speed of marker
numStepsnumber Number of steps to divide the marker path
-
Name Type Description featuremodule:cercaliagl/Feature~Feature Feature
layermodule:cercaliagl/layer/Feature~Feature Feature layer
callbackFnfunction callback function when finished
-
Name Type Description baseLayermodule:cercaliagl/layer/XYZ~XYZ | module:cercaliagl/layer/WMS~WMS Base layer
mapTypestring | undefined Map type
-
Add custom control. You can specify children position inside control container. Default append to last child.
Name Type Description controlmodule:cercaliagl/control/Custom~Custom Custom control.
positionnumber Position.
-
Name Type Description featuremodule:cercaliagl/Feature~Feature Feature
layermodule:cercaliagl/layer/Feature~Feature Feature layer
updateGeoJSONboolean (defaults to true) Update GeoJSON after add feature, true by default
-
Name Type Description featuresArray.<module:cercaliagl/Feature~Feature> Features
layermodule:cercaliagl/layer/Feature~Feature Feature layer
-
Name Type Description idstring id
labelstring label
baseLayersArray.<(module:cercaliagl/layer/XYZ~XYZ|module:cercaliagl/layer/WMS~WMS)> Base layers
mapTypestring | undefined Map type
-
Add layer
Name Type Description layermodule:cercaliagl/layer/Base~LayerLike Layer
beforeLayerIdstring Before layer id. Only when base layer is MVT type.
-
Name Type Description markermodule:cercaliagl/Marker~Marker Marker
layermodule:cercaliagl/layer/Marker~Marker -
Name Type Description markersArray.<module:cercaliagl/Marker~Marker> Marker
layermodule:cercaliagl/layer/Marker~Marker Layer
-
Center on current GPS position
-
Name Type Description featuresArray.<module:cercaliagl/Feature~Feature> Features
optionsOptions
Name Type Description animationboolean Animation.
durationnumber Duration if animation is enabled. Default
2000.changeZoomboolean Change zoom
zoomnumber zoom to change
-
Name Type Description markersArray.<module:cercaliagl/Marker~Marker> Markers
optionsOptions
Name Type Description animationboolean Animation.
durationnumber Duration if animation is enabled. Default
2000.changeZoomboolean Change zoom
zoomnumber zoom to change
-
Available layers.
cercaliagl.MapTypes.CERCALIAcercaliagl.MapTypes.SATELLITEcercaliagl.MapTypes.OSMcercaliagl.MapTypes.DARKcercaliagl.MapTypes.SILVERcercaliagl.MapTypes.BLANKMAPcercaliagl.MapTypes.GOOGLE_STYLEcercaliagl.MapTypes.GOOGLE_STYLE_V2cercaliagl.MapTypes.GOOGLE_STYLE_TRANSPARENTcercaliagl.MapTypes.EMPTY
Name Type Description baseLayerstring Base layer
-
Close all menus and reset nav bar menu view.
-
Close all open popups
Name Type Description layermodule:cercaliagl/layer/Marker~Marker | undefined -
Returns the pixel value from a coordinate
Name Type Description coordinatemodule:cercaliagl/LonLat~LonLat Coordinate.
Returns:
Return pixel of map.
-
Disable marker clustering. Only available for
module:cercaliagl/layer/Marker~Markerlayer.Name Type Description layerIdstring Layer id. Default
LayersId.MARKERS_LAYER_ID. -
Disable draw interaction
-
Name Type Description layerIdstring Layer id. Default
LayersId.MARKERS_LAYER_ID. -
Enable marker clustering. Only available for
module:cercaliagl/layer/Marker~Markerlayer.Name Type Description optionsClustering options
Name Type Description layerIdstring Layer id. Default
LayersId.MARKERS_LAYER_ID.onClickfunction Click over callback function.
onMouseOverfunction Mouse over callback function.
onMouseOutfunction Mouse out callback function.
maxZoomnumber Max zoom for clustering. Default
16.radiusnumber Radius in pixels to cluster. Default
40. -
Enable draw interaction
Name Type Description typestring Available values
line|polygon|draw_magnetic_polygon|circle|freehand_polygonoptionsDraw options
Name Type Description onDrawEndfunction 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.styleHeatZonesproperty 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.styleHeatPointsproperty 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 optionsHeatmap layer options
Name Type Description layerIdstring Layer id. Default
LayersId.MARKERS_LAYER_ID.styleHeatZonesmodule:cercaliagl/layer/Marker~StyleHeatLayer Style layer zone. Read MapboxGL documentation https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#heatmap.
styleHeatPointsmodule:cercaliagl/layer/Marker~StyleHeatLayer Point layer zone. Use layer
type: circlestyles. https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle -
Export PNG image
Name Type Description filenamestring (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 namestring Name
-
Get marker by ID. It returns null if it is not found.
Name Type Description idstring Id.
layermodule:cercaliagl/layer/Feature~Feature Marker layer.
Returns:
marker Marker ornullif not found.
-
Name Type Description layermodule:cercaliagl/layer/Feature~Feature -
Returns:
Geolocation
-
Returns:
Language
-
Get layer by id
Name Type Description layerIdstring 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 idstring Id.
layermodule:cercaliagl/layer/Marker~Marker Marker layer.
Returns:
marker Marker ornullif not found.
-
Name Type Description layermodule: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 layermodule:cercaliagl/layer/Marker~Marker | undefined -
-
Name Type Description eventNamestring Event name
callbackFnfunction Callback function
-
Name Type Description eventNamestring Event name
callbackFnfunction 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 centermodule:cercaliagl/LonLat~LonLat Coordinate
-
Show all markers popups. Only for markers with popup created
-
Moves the map to the new center
Name Type Description positionmodule:cercaliagl/LonLat~LonLat Coordinates.
animationboolean (defaults to true) Enable or disable animation. Default
true. -
Map center maintaining the zoom level
Name Type Description boundsmodule:cercaliagl/Bounds~Bounds Mapbounds.
animationboolean Enable or disable animation. Default
true. -
Calculate the real distance in meters, from pixels values.
Name Type Description pixelsnumber Pixels to measure
Returns:
meters Return measure in meters.
-
Returns the coordinate from a pixel value
Name Type Description pixelmodule:maplibre-gl~PointLike pixel of map.
Returns:
Coordinate
-
Name Type Description layermodule:cercaliagl/layer/Feature~Feature Feature layer
-
Name Type Description layermodule:cercaliagl/layer/Marker~Marker -
Name Type Description featuremodule:cercaliagl/Feature~Feature Feature
layermodule:cercaliagl/layer/Feature~Feature Feature layer
-
Name Type Description featuresArray.<module:cercaliagl/Feature~Feature> Features
layermodule:cercaliagl/layer/Feature~Feature Feature layer
-
Remove layer
Name Type Description layermodule:cercaliagl/layer/Base~LayerLike Layer
-
Name Type Description markermodule:cercaliagl/Marker~Marker Marker
layermodule:cercaliagl/layer/Marker~Marker Layer
-
Name Type Description markersArray.<module:cercaliagl/Marker~Marker> layermodule:cercaliagl/layer/Marker~Marker -
Rotates the map
degrees, by parameter Name Type Description anglenumber Angle (degrees).
animationboolean (defaults to true) Animation. Default
true. -
Set the map center
Name Type Description lonLatmodule:cercaliagl/LonLat~LonLat Coordinates
zoomnumber Zoom
animationboolean (defaults to false) Enable or disable animation. Default
true.speednumber (defaults to 1) Speed animation. Default 1.
-
Name Type Description contextMenumodule:cercaliagl/ContextMenu~ContextMenu Context menu
-
Set default click function. When map is clicked parameter function is triggered.
Name Type Description funcfunction | undefined Function
-
Name Type Description langstring Language
-
Name Type Description pitchnumber Pitch
animationboolean (defaults to true) Animation. Default
true. -
Sets the map rotation
Name Type Description bearingnumber Angle in degrees.
animationboolean (defaults to true) Animation. Default
true. -
Set the zoom level of map. If second parameter is specified (boolean, optional)
Name Type Description zoomnumber Zoom level to adjust
-
Show 3D buildings in close zooms.
Name Type Description visibleboolean Visible or not.
showToBuildingsboolean (defaults to false) Buildings
-
Show map controls
-
Name Type Description infoMapmodule:cercaliagl/InfoMap~InfoMap Info map.
-
show all marker labels
Name Type Description layermodule: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