new cercalia.Map(options)
| Name | Type | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Map options
|
|||||||||||||||||||||||||||||||
Extends
Members
-
cercalia.Map.DefaultMapControls{}
-
Methods
-
addBaseLayer(baseLayer)
src/cercalia/map.js, line 1577 -
Add base layer. Only when layer switcher control is available.
Name Type Description baseLayercercalia.BaseLayer Base layer.
-
addControl(control, opt_position)
src/cercalia/map.js, line 2893 -
Add the given control to the map.
Name Type Description controlcercalia.control.Control | ol.control.Control Control.
positionnumber Position.
-
addCustomControl(control, opt_position)
src/cercalia/map.js, line 2931 -
Add custom control. You can specify children position inside control container. Default append to last child.
Name Type Description controlcercalia.control.Custom Custom control.
positionnumber Position.
-
addFeature(feature, opt_layer)
src/cercalia/map.js, line 2071 -
Paint
cercalia.Featurelist on the map.Name Type Description featurecercalia.Feature Feature
layerol.layer.Layer Layer.
-
addFeatures(features, opt_layer)
src/cercalia/map.js, line 2082 -
Paint
cercalia.Featureon the map.Name Type Description featuresList of features.
layerol.layer.Layer Layer.
-
addLayer(layer, opt_position, opt_draggable)
src/cercalia/map.js, line 1280 -
Adds a layer
ol.layer.Layerspecifying the position (optional). The layers are declarated in an array and the Z value works from less to more. The Layer basemap (map), is fixed in the first position 0.
If you need to change the baseLayer, change it to position 1 or remove the baseLayer.Name Type Description layerol.layer.Layer | ol.layer.Group | cercalia.Heatmap | cercalia.KML | cercalia.WMS Layer to add.
positionnumber Position in array (like zIndex)
draggableboolean If layer object is instanceof
ol.layer.Vector. Optionally can disable drag events for performance. Defaulttrue. -
addMarker(marker, opt_layer)
src/cercalia/map.js, line 2026 -
Paint
cercalia.Markerlist on the map.Name Type Description markercercalia.Marker Marker to add.
layerol.layer.Layer Layer
-
addMarkers(markers, opt_layer)
src/cercalia/map.js, line 2037 -
Paint on the map the
cercalia.Markerlist. In this function must send anArray.Name Type Description markersList of markers.
layerol.layer.Layer Lyaer
-
addWMSLayer(wmsLayer, position)
src/cercalia/map.js, line 1988 -
Adds a WMS layer
cercalia.WMSto the mapName Type Description wmsLayercercalia.WMS WMS Layer.
positionnumber WMSLayer position. If not declared, it's included just one level over the basemap.
-
centerToFeatures(features, opt_changeZoom, opt_animation)
src/cercalia/map.js, line 1708 -
Center the map
Name Type Description featuresArray.<cercalia.Feature> | cercalia.Feature Features list or object.
changeZoomboolean Change zoom on features center. Default:
true.animationboolean Enable or disable animation. Default
true. -
centerToMarkers(opt_markers, opt_changeZoom, opt_animation)
src/cercalia/map.js, line 1651 -
Centers the map to the markers list. Optionally it's possible to change the zoom for including all the markers. If markers array is not specified, by default centers to all markers
Name Type Description markersList Markers, if not specified center to all markers.
changeZoomboolean Default
true.animationboolean Enable or disable animation. Default
true. -
changeLogo(opt_content)
src/cercalia/map.js, line 1258 -
Change page logo. If content is null, then it restores default logo.
Name Type Description contentstring HTML content
-
closeAll()
src/cercalia/map.js, line 2973 -
Close all menus and reset nav bar menu view.
-
closePopups()
src/cercalia/map.js, line 2382 -
Close all open popups
-
Returns the pixel value from a coordinate
Name Type Description lonLatcercalia.LonLat Coordinate.
Returns:
Return pixel of map.
-
createStaticMap(callbackFn)
src/cercalia/map.js, line 3115 -
Name Type Description callbackFnfunction Callback function
-
disableClustering()
src/cercalia/map.js, line 2640 -
Disable markers clustering. Every marker will be painted singly, with its icon.
-
disableDrawInteraction()
src/cercalia/map.js, line 2880 -
Disable the painting status
-
disableSnapping()
src/cercalia/map.js, line 2772 -
-
enableClustering(opt_distance, opt_clickFunction, opt_mouseOverFunction, opt_doubleClickFunction, opt_mouseOutFunction)
src/cercalia/map.js, line 2534 -
Enable markers clustering. Note: When clustering is enabled drag markers won't work.
Name Type Default Description distancenumber 40 Distance, in pixels, to group markers with clusters. Default value: 40.
clickFunctionfunction Call function on cluster click.
Parameters avaliable (clusterFeature, features).
First parameter it's an objectol.Featurevisible on map as a cluster,
Second parameter it's acercalia.Markerarray objects with the features contained in a cluster.mouseOverFunctionfunction Call function on cluster mouseover. Same parameters used in 'clickFunction' event
doubleClickFunctionfunction Call function on double click on cluster.
Parameters avaliable (clusterFeature, features).mouseOutFunctionfunction Call function on cluster mouseout. Same parameters used in 'clickFunction' event
-
enableDrawInteraction(type, opt_dragFeatures, opt_styles, opt_drawEndFunction, opt_freehand)
src/cercalia/map.js, line 2789 -
Enable the painting status. The features can be draggables, changing the features styles.
Name Type Description typestring Type
[Point|LineString|Polygon|Circle|Square|Rectangle]dragFeaturesboolean Boolean.
trueorfalse.stylesObject JS object with the style values:
{strokeColor, strokeWidth, strokeOpacity, fillColor, fillOpacity, radius}. For example:{strokeColor:'#ff0000',fillColor:'#00ff00',radius:5,fillOpacity:0.5}drawEndFunctionfunction Call function when user finish drawing the feature. Send the same feature painted
freehandboolean Operate in freehand mode for lines, polygons, and circles. This makes the interaction always operate in freehand mode
-
enableMouseOverEvents(enable)
src/cercalia/map.js, line 756 -
Enable or disable mouse over/out events. When there are thousands markers drawn then map has poor performance, so its recommended to disable
Name Type Description enableboolean Enable or disable
-
enableSnapping()
src/cercalia/map.js, line 2761 -
-
exportPNG(opt_filename)
src/cercalia/map.js, line 2941 -
Export PNG image
Name Type Description filenamestring | undefined Filename.
-
fitBounds(bounds, opt_animation, opt_size)
src/cercalia/map.js, line 1770 -
Fit the bounds: change the current map bounds to new bounds.
Name Type Description boundscercalia.Bounds New bounds
animationboolean Enable or disable animation. Default
true.sizeol.Size Size in pixel of the box to fit the extent into.
-
Returns the layer (ol.layer.Tile) used as basemap
Returns:
Return baselayer
-
Returns the current bounds
Returns:
Current bounds, according to the zoom level, position and widht-height
-
Returns the map center.
Returns:
Return center coordinatescercalia.LonLat. Undefined if map is not setted.
-
Returns:
Get Class name of object
-
Name Type Description positioncercalia.LonLat Position
layerol.layer.Layer Layer
Returns:
Nearest feature to coordinate
-
Name Type Description positioncercalia.LonLat Position
layerol.layer.Layer Layer
Returns:
Nearest marker to coordinate
-
getContainerId(){string}
src/cercalia/map.js, line 1346 -
Returns the container ID
Returns:
id Map container Id
-
Returns:
Get contextmenu.
-
Obtains the map control from its name. Complete controls list (if are created):
cercalia.control.MapControls.ADDRESScercalia.control.MapControls.CLEANcercalia.control.MapControls.GAS_STATIONScercalia.control.MapControls.LAYER_SWITCHERcercalia.control.MapControls.ISOCHRONEScercalia.control.MapControls.LOGISTICS_RESTRICTIONScercalia.control.MapControls.LAYER_REGIONScercalia.control.MapControls.METEOcercalia.control.MapControls.NAVBARcercalia.control.MapControls.TRAFFICcercalia.control.MapControls.ZOOM
Name Type Description namestring Name of control
Returns:
Control.
-
getControlsByClassName(className){}
src/cercalia/map.js, line 1623 -
Obtains the map control from its class name. Complete controls list (if are created):
- `cercalia.control.Address
- `cercalia.control.Clean
- `cercalia.control.GasStations
- `cercalia.control.LayerSwitcher
- `cercalia.control.Meteo
- `cercalia.control.NavBar
- `cercalia.control.Traffic
cercalia.control.Zoom
Name Type Description classNamestring Classname of control
Returns:
Control.
- `cercalia.control.Address
-
Name Type Description evtol.MapEvent Event
Returns:
Position
-
Obtains pixel
Name Type Description evtol.MapEvent Event
Returns:
pixel Pixel
-
Obtain all the
cercalia.Featurepainted on the mapReturns:
Feature list painted on the map
-
getFeaturesByLayer(layer){Array.<cercalia.Marker>|Array.<cercalia.Feature>}
src/cercalia/map.js, line 2143 -
Get Cercalia Markers and Features (ignoring features created directly by ol.Feature)
Name Type Description layerol.layer.Layer Layer
Returns:
list of markers or features.
-
Returns:
Geolocation
-
Returns:
Unique Id.
-
Name Type Description layerNamestring Name of layer.
Returns:
OpenLayers layer.
-
getLayerIndexByName(layerName){number|null}
src/cercalia/map.js, line 2007 -
Obtains the layer position (Z value). The layers are painted respecting Z position: 0 is the base map.
Name Type Description layerNamestring Name of layer.
Returns:
Layer position
-
Returns the OpenLayers3 object
ol.MapReturns:
Map
-
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.
layerol.layer.Layer Optional layer. Default uses
MarkerLayer.Returns:
marker Marker ornullif not found.
-
Obtain all the
cercalia.Markerpainted on the mapReturns:
Marker list painted on the map
-
getOverlappedMarkers(currentExtentView, opt_tolerance){}
src/cercalia/map.js, line 2413 -
Get Overlapped markers
Name Type Description currentExtentViewboolean | undefined If
truereturns only visible markers at the moment, if notnullorfalseit returns all markerstolerancenumber Tolerance in meters.
Returns:
Array of group (array) of features.
-
getProjectionCode(){string}
src/cercalia/map.js, line 1844 -
Obtains the map projection code
Returns:
EPSG code. For example:EPSG:3857.
-
getRotation(){number}
src/cercalia/map.js, line 1824 -
Returns:
Rotation in degrees.
-
getScaleUnits(){string}
src/cercalia/map.js, line 1354 -
Returns:
Scale units
-
getViewportSize(){}
src/cercalia/map.js, line 3100 -
Get viewport size
Returns:
Return {w: width, h: height}
-
getZoom(){number|undefined}
src/cercalia/map.js, line 1417 -
Returns:
Current zoom level of map.
-
hideControls()
src/cercalia/map.js, line 1631 -
Hide all map controls.
-
hideLabels()
src/cercalia/map.js, line 2347 -
Hide all labels
cercalia.Labelfrom markers painted on the map -
metersToPixels(meters){number|undefined}
src/cercalia/map.js, line 1496 -
Calculate in pixels, from distance in meters on current map bounds (no geodesic distance).
Name Type Description metersnumber Meters
Returns:
meters Return measure in meters.
-
openContextMenu(opt_lonLat)
src/cercalia/map.js, line 977 -
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 lonLatcercalia.LonLat Coordinate
-
openPopups()
src/cercalia/map.js, line 2396 -
Show all markers popups. Only for markers with popup created
-
panTo(lonLat, opt_animation)
src/cercalia/map.js, line 1788 -
Moves the map to the new center
Name Type Description lonLatcercalia.LonLat Coordinates.
animationboolean Enable or disable animation. Default
true. -
panToBounds(bounds, opt_animation)
src/cercalia/map.js, line 1804 -
Map center maintaining the zoom level
Name Type Description boundscercalia.Bounds Mapbounds.
animationboolean Enable or disable animation. Default
true. -
pixelsToMeters(pixels){number|undefined}
src/cercalia/map.js, line 1480 -
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 pixelol.Pixel Pixel
Returns:
Coordinate
-
removeAllFeatures()
src/cercalia/map.js, line 2273 -
Clean all features
-
removeAllMarkers()
src/cercalia/map.js, line 2262 -
Clean all markers and popups
-
removeAllOverlays()
src/cercalia/map.js, line 2300 -
Clean all overlays painted on the map
-
removeDrawFeatures()
src/cercalia/map.js, line 2286 -
Clean all the features painted on the map with draw tool. Layer 'DrawLayer'
-
removeFeatures(features, opt_layer)
src/cercalia/map.js, line 2212 -
Remove features list from map
Name Type Description featurescercalia.Feature | Array.<cercalia.Feature> Feature or list of features.
layerol.layer.Layer If not defined it will remove features in internal Cercalia layer.
-
removeLayer(layer)
src/cercalia/map.js, line 1312 -
Clean the layer specified by parameter
Name Type Description layerol.layer.Layer | ol.layer.Vector | cercalia.KML | cercalia.WMS | cercalia.Heatmap Layer to remove.
-
removeMarkers(markers, opt_layer)
src/cercalia/map.js, line 2178 -
Remove markers list from map
Name Type Description markerscercalia.Marker | Array.<cercalia.Marker> Marker or list of markers to remove.
layerol.layer.Layer If not defined it will remove features in internal Cercalia layer.
-
removeWMSLayer(wmsLayer)
src/cercalia/map.js, line 1997 -
Remove a WMS layer
cercalia.WMSfrom the mapName Type Description wmsLayercercalia.WMS WMS Layer to remove.
-
rotate(angle)
src/cercalia/map.js, line 1834 -
Rotates the map
degrees, by parameter Name Type Description anglenumber Angle (degrees).
-
setBaseLayer(mapType)
src/cercalia/map.js, line 1177 -
Name Type Description mapTypestring | cercalia.WMS | ol.layer.Layer | ol.layer.Group Change base map.
Maps avaliable by default. String:cercalia.MapTypes.CERCALIACercaliacercalia.MapTypes.OSMCercaliacercalia.MapTypes.SATELLITE
Also can use your own custom base layers. Also can use a WMS layer (object cercalia.WMS), that will be set as base Layer. Also can add layers using OpenLayers classesol.layer.Layeryol.layer.Group.
-
setCenter(lonLat, opt_zoom, opt_animation)
src/cercalia/map.js, line 1398 -
Set the map center
Name Type Description lonLatcercalia.LonLat Coordinates
zoomnumber Zoom
animationboolean Enable or disable animation. Default
true. -
setDefaultClick(func)
src/cercalia/map.js, line 2744 -
Set default click function. When map is clicked parameter function is triggered.
Name Type Description funcfunction | undefined Function
-
setFeatureDrawingStyles(styles)
src/cercalia/map.js, line 2857 -
Name Type Description stylesObject Styles.
-
setGreyScale(enable)
src/cercalia/map.js, line 3021 -
Change base map colors to grey ssacle
Name Type Description enableboolean Enable
-
setProjection(projection, opt_layer)
src/cercalia/map.js, line 1881 -
Changes the projection to basemap and all the layers painted over it (markers, features, WMS, etc).
Name Type Description projectionol.proj.Projection Projection.
layerol.layer.Layer Layer. Optional.
-
setRestrictedView(minZoom, maxZoom, bounds)
src/cercalia/map.js, line 1856 -
Fixes the minimum and maximum zoom level
Name Type Description minZoomnumber | boolean Min zoom, false if don't want this limit
maxZoomnumber | boolean Max zoom, false if don't want this limit
boundscercalia.Bounds Map bounds limits
-
setRotation(angle)
src/cercalia/map.js, line 1816 -
Sets the map rotation
Name Type Description anglenumber Angle in degrees.
-
setZoom(zoom)
src/cercalia/map.js, line 1426 -
Set the zoom level of map. If second parameter is specified (boolean, optional)
Name Type Description zoomnumber Zoom level to adjust
-
showControls()
src/cercalia/map.js, line 1639 -
Show all map controls.
-
showInfoMap(infoMap)
src/cercalia/map.js, line 2962 -
Name Type Description infoMapcercalia.InfoMap Info map.
-
showingLabels(){boolean}
src/cercalia/map.js, line 2374 -
Returns boolean showing if all labels are showing or hidden.
Returns:
Return wheter labels are visible.
-
showLabels()
src/cercalia/map.js, line 2361 -
Show all labels
cercalia.Labelfrom markers painted on the map -
showMarkers(markers, show)
src/cercalia/map.js, line 2162 -
Show the markers painted on the map. This function is usefull when some or all markers are hidden.
Name Type Description markerscercalia.Marker | Array.<cercalia.Marker> Marker or list of markesrs.
showboolean Show markers. (
trueorfalse). -
updateSize()
src/cercalia/map.js, line 3091 -
Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport.