new cercalia.Map(options)
Name | Type | Description |
---|---|---|
options |
cercaliax.MapOptions |
Map options |
Members
-
overlayLoading
-
"Loading" overlay, blocks the map use
Methods
-
addControl(control)
-
Add a control in the map, by parameter
Name Type Description control
cercalia.Control -
addFeature(feature, layer)
-
Paint
cercalia.Feature
on the map.Name Type Description feature
cercalia.Feature layer
ol.Layer | undefined optional -
addFeatures(features, layer)
-
Paint several
cercalia.Feature
on the map. Must send anArray
.Name Type Description features
Array.<cercalia.Feature> Array de
cercalia.Feature
layer
ol.layer -
addLayer(layer, position)
-
Adds a layer
ol.layer.Layer
specifying 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 layer
ol.layer position
number -
addLinestring(linestring)
-
Paint
cercalia.Linestring
on the mapName Type Description linestring
cercalia.Linestring -
addLinestrings(linestrings)
-
Paint on the map the
cercalia.Linestring
list. In this function must send anArray
.Name Type Description linestrings
Array.<cercalia.Linestring> -
addMarker(marker)
-
Paint
cercalia.Marker
list on the map.Name Type Description marker
cercalia.Marker -
addMarkers(markers)
-
Paint on the map the
cercalia.Marker
list. In this function must send anArray
.Name Type Description markers
Array.<cercalia.Marker> -
addWMSLayer(wmsLayer, position)
-
Adds a WMS layer
cercalia.WMS
to the mapName Type Description wmsLayer
cercalia.WMS position
number WMSLayer position. If not declared, it's included just one level over the basemap.
-
boundsInsidePolygon_(bounds, polygon){boolean}
-
Check if bounds are inside a WKT polygon
Name Type Description bounds
cercalia.Bounds Map bounds
polygon
string WKT Polygon
Returns:
True if inside
-
centerToFeatures(features, changeZoom, animation)
-
Center the map
Name Type Description features
Array.<cercalia.Feature> | cercalia.Feature Features list or object.
changeZoom
number Change zoom on features center. Default: true
animation
boolean Animation. Default: true
-
centerToMarkers(markers, changeZoom, animation)
-
Centers the map with animation (or not) 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 markers
Array.<cercalia.Marker> | undefined optional changeZoom
boolean Default: true
animation
boolean Default: true
-
clearCercaliaServices()
-
Resets services
-
closePopups()
-
Close all popups opened
-
coordToPixel(lonLat){ol.Pixel}
-
Returns the pixel value from a coordinate
Name Type Description lonLat
cercalia.LonLat -
createContextMenuOption(buttonName, clickFunction, id)
-
Add a new option in context menu, adding a function on click to this option.
Name Type Description buttonName
string Text to show in the neu context menu option
clickFunction
function Function to call linked to new button
id
string Option's identifier.
-
createTopBar(){Element}
-
Create topbar
-
createWMSPOIs(categories)
-
Create a WMS POIs layer, specifying the categories to be painted.
Contact with Nexus Geografics for additional information and use.Name Type Description categories
Array.<string> | string -
deactivateControls()
-
Disable the active controls
-
destroy()
-
Destroy function
-
disableClustering()
-
Disable markers clustering. Every marker will be painted singly, with its icon.
-
disableDrawInteraction()
-
Disable the painting status
-
enableClustering(distance, clickFunction, mouseOverFunction, doubleClickFunction, mouseOutFunction)
-
Enable markers clustering. Note: When clustering is enabled drag markers won't work.
Name Type Default Description distance
number | undefined 40 optional Distance, in pixels, to group markers with clusters. Default value: 40.
clickFunction
function | undefined optional Call function on cluster click.
Parameters avaliable (clusterFeature, features).
First parameter it's an objectol.Feature
visible on map as a cluster,
Second parameter it's acercalia.Marker
array objects with the features contained in a cluster.mouseOverFunction
function | undefined optional Call function on cluster mouseover. Same parameters used in 'clickFunction' event
doubleClickFunction
function | undefined optional Call function on double click on cluster.
Parameters avaliable (clusterFeature, features).mouseOutFunction
function | undefined optional Call function on cluster mouseout. Same parameters used in 'clickFunction' event
-
enableDrawInteraction(type, dragFeatures, styles, drawEndFunction)
-
Enable the painting status. The features can be draggables, changing the features styles.
Name Type Description type
string Type
[Point|LineString|Polygon|Circle]
dragFeatures
boolean | undefined optional Boolean.
true
orfalse
.styles
Object | undefined optional JS object with the style values:
[strokeColor, strokeWidth, strokeOpacity, fillColor, fillOpacity, radius]
. For example:{strokeColor:'#ff0000',fillColor:'#00ff00',radius:5,fillOpacity:0.5}
drawEndFunction
function | undefined optional Call function when user finish drawing the feature. Send the same feature painted
-
enableFeatureEditable(enable)
-
Set the features as editables if it isn't, or change to not editable if it's editable.
Name Type Description enable
boolean Set on/off the editable mode.
-
exportPNG(filename)
-
Export PNG image
Name Type Description filename
string | undefined optional -
fitBounds(bounds, animation)
-
Fit the bounds: change the current map bounds to new bounds. By default applies animation effect
Name Type Description bounds
cercalia.Bounds New bounds
animation
boolean True/False, if want to apply animation or not. Default: true
-
geolocation(callbackFn)
-
Obtains the geocode at the API access point It is possible to declare a callback function, to be executed when obtains the geocode. When callback function is not avaliable, the map is centered to API access point.
Name Type Description callbackFn
function -
getBaseLayer(){ol.layer.Tile}
-
Returns the layer (ol.layer.Tile) used as basemap
-
getBounds(){cercalia.Bounds}
-
Returns the current bounds
Returns:
Current bounds, according to the zoom level, position and widht-height
-
getCenter(){cercalia.LonLat}
-
Returns the map center.
Returns:
Coordinates.
-
getClass(){string}
-
Returns:
Object ClassName. Value:cercaila.Map
.
-
getClosestFeature(position){cercalia.Feature}
-
Name Type Description position
cercalia.LonLat Returns:
Nearest feature to coordinate
-
getClosestMarker(position){cercalia.Marker}
-
Name Type Description position
cercalia.LonLat Returns:
Nearest marker to coordinate
-
getContextMenuOverlay(){ol.Overlay}
-
-
getControlsByName(controlName){ol.Control}
-
Obtains the map control from its name. Complete controls list (if are created):
cercalia.MapControls.CleanControl
cercalia.MapControls.DragControl
cercalia.MapControls.DrawControl
cercalia.MapControls.FullScreen
cercalia.MapControls.LayerSwitcher
cercalia.MapControls.Logistics
cercalia.MapControls.MeasureControl
cercalia.MapControls.MeteoControl
cercalia.MapControls.RotateNorth
cercalia.MapControls.ScaleLine
cercalia.MapControls.StreetView
cercalia.MapControls.Traffic
cercalia.MapControls.Zoom
cercalia.MapControls.ZoomSlider
Name Type Description controlName
string -
getDragInteraction(){ol.interaction.DragInteraction}
-
Returns the drag interaction.
-
getDrawInteraction(){ol.interaction.DrawInteraction}
-
Returns the draw interaction.
-
getDrawLayer(){ol.layer.Vector}
-
Returns the layer (
ol.layer.Vector
) used for painting on the map.Returns:
layer
-
getEventCoordinate(evt){cercalia.LonLat}
-
Name Type Description evt
event -
getEventPixel(evt){Pixel}
-
Obtains pixel
Name Type Description evt
event -
getFeatures(){Array.<cercalia.Linestring>|null}
-
Obtain all the
cercalia.Feature
painted on the mapReturns:
Linestring list painted on the map
-
getId(){string}
-
Returns the map internal ID.
Returns:
map internal ID.
-
getInteractionDrag(){cercalia.Interaction.DragFeatures}
-
Returns:
dragInteraction
-
getLayerByName(layerName){ol.layer}
-
Name Type Description layerName
string Returns:
Layer objeto ol3
-
getLayerIndexByName(layerName){number}
-
Obtains the layer position (Z value). The layers are painted respecting Z position: 0 is the base map.
Name Type Description layerName
string Returns:
Layer position
-
getLinestrings(){Array.<cercalia.Linestring>|null}
-
Obtain all the
cercalia.Linestring
painted on the mapReturns:
Linestrings list painted on the map
-
getMainMenu(){cercalia.widget.MainMenu}
-
Returns:
Returns the reference tocercalia.widget.MainMenu
-
getMap(){ol.Map}
-
Returns the OpenLayers3 object
ol.Map
Returns:
Map
-
getMarkerById(){cercalia.Marker}
-
Returns:
marker
-
getMarkers(){Array.<cercalia.Marker>|null}
-
Obtain all the
cercalia.Marker
painted on the mapReturns:
Marker list painted on the map
-
getOverlappedMarkers(currentExtentView, tolerance){Array.<Array.<cercalia.Marker>>}
-
Get Overlapped markers
Name Type Description currentExtentView
boolean | undefined optional If
true
returns only visible markers at the moment, if notnull
orfalse
it returns all markerstolerance
boolean | undefined optional Tolerance in meters.
-
getProjectionCode(){string}
-
Obtains the map projection code
Returns:
EPSG code. For example:EPSG:3857
.
-
getRightClickMenuOptions(){array.<string>}
-
Returns:
return rightClick menu options.
-
getRouteMap(){cercalia.RouteMap}
-
Returns:
routeMap
-
getScaleUnits()
-
Returns:
scale units. Valuesmetric
orimperial
-
getViewOptions(){Object}
-
Returns:
View options from cercalia map.
-
getZoom(){number}
-
Returns:
Current zoom level of map.
-
hideAllControls()
-
Hide all controls
-
hideLabels()
-
Hide all labels
cercalia.Label
from markers painted on the map -
hideLoading()
-
Hide "Loading..."
-
openContextMenu(lonLat)
-
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
cercalia.LonLat | undefined optional Coordinate
-
openPopups()
-
Show all markers popups. Only for markers with popup created
-
overlapMarkers()
-
Separate overlapped markers when its have same position.
-
panTo(lonLat, animation, duration)
-
Moves the map to the new center. Optional: animation effect-
Name Type Description lonLat
cercalia.LonLat Coordinate
animation
string Boolean animation effect. Values
true
orfalse
, specifying the type of animation:cercalia.MapAnimation.ROTATE_LEFT
,cercalia.MapAnimation.ROTATE_RIGHT
,cercalia.MapAnimation.PAN
,cercalia.MapAnimation.ELASTIC
,cercalia.MapAnimation.BOUNCE
,cercalia.MapAnimation.FLY
,cercalia.MapAnimation.SPIRAL
duration
number Animation duration (in miliseconds). Defaulf
2000
. -
panToBounds(bounds, animation, duration)
-
Map center maintaining the zoom level
Name Type Description bounds
cercalia.Bounds Mapbounds.
animation
boolean Boolean for apply or not animation effect. Values:
true
orfalse
.duration
number Animation duration (in miliseconds). Default
2000
. -
pixelsToMeters(pixels){number}
-
Calculate the real distance in meters, from pixels values.
Name Type Description pixels
number Returns:
meters
-
pixelToCoord(pixel){cercalia.LonLat}
-
Returns the coordinate from a pixel value
Name Type Description pixel
ol.Pixel Returns:
Coordinate
-
removeAllFeatures()
-
Clean all features
-
removeAllLinestrings()
-
Clean all linestrings
-
removeAllMarkers()
-
Clean all markers and popups
-
removeAllOverlays()
-
Clean all overlays painted on the map
-
removeApiMarkers(markers)
-
Remove API markers list from map
Name Type Description markers
cercalia.Marker | Array.<cercalia.Marker> -
removeApiRoute()
-
- Deprecated
- deprecated function, equivalent: map.getRouteMap().removeRoute();
-
removeDrawFeatures()
-
Clean all the features painted on the map with draw tool. Layer 'DrawLayer'
-
removeFeatures(features, layer)
-
Remove features list from map
Name Type Description features
cercalia.Feature | Array.<cercalia.Feature> layer
ol.Layer | undefined optional If not defined it will remove features in internal Cercalia layer.
-
removeLayer(layer)
-
Clean the layer specified by parameter
Name Type Description layer
ol.layer -
removeLinestrings(linestrings)
-
Remove linestring list from map
Name Type Description linestrings
cercalia.Linestring | Array.<cercalia.Linestring> -
removeMarkers(markers)
-
Remove markers list from map
Name Type Description markers
cercalia.Marker | Array.cercalia.Marker -
removeWMSLayer(wmsLayer)
-
Remove a WMS layer
cercalia.WMS
from the mapName Type Description wmsLayer
cercalia.WMS -
removeWMSPOIs()
-
Clean POIs layers, if painted
-
rotate(angle)
-
Rotates the map
degrees, by parameter Name Type Description angle
number Angle (degrees).
-
setBaseLayer(mapType)
-
Name Type Description mapType
string | cercalia.WMS | ol.layer.Layer | ol.layer.Group Change base map.
Maps avaliable by default. String:cercalia.MapTypes.CERCALIA
Cercaliacercalia.MapTypes.OSM
Cercaliacercalia.MapTypes.SATELLITE
cercalia.MapTypes.HYBRID
Also can use a WMS layer (object cercalia.WMS), that will be set as base Layer. Also can add layers using OpenLayers classesol.layer.Layer
yol.layer.Group
.
-
setCenter(lonLat, zoom, animation)
-
Set the map center
Name Type Description lonLat
cercalia.LonLat Coordinates
zoom
number Zoom
animation
boolean | undefined optional Animation, activated by default
-
setDefaultClick(func)
-
Name Type Description func
function | undefined optional Function
-
setFeatureEditable(feature, edit)
-
Set feature editable.
Name Type Description feature
cercalia.Feature Feature to be edited.
edit
boolean Set the feature as editable or not.
-
setProjection(projection)
-
Changes the projection to basemap and all the layers painted over it (markers, features, WMS, etc).
Name Type Description projection
ol.Projection Projection.
-
setRestrictedView(minZoom, maxZoom, bounds)
-
Fixes the minimum and maximum zoom level
Name Type Description minZoom
number | boolean Min zoom, false if don't want this limit
maxZoom
number | boolean Max zoom, false if don't want this limit
bounds
cercalia.Bounds Map bounds limits
-
setRightClickMenuOptions(Set)
-
Name Type Description Set
array.<string> rightClick menu options.
-
setRotation(angle)
-
Sets the map rotation
Name Type Description angle
number -
setRouteMap(routeMap)
-
Name Type Description routeMap
cercalia.RouteMap -
setZoom(zoom, animation)
-
Set the zoom level of map. If second parameter is specified (boolean, optional), can apply animation effect
Name Type Description zoom
number Zoom level to adjust
animation
boolean True/False if want to apply animation effect. Defaulf: true
-
showAllControls()
-
Show all controls
-
showingLabels(){Boolean}
-
Returns boolean showing if all labels are showing or hidden.
-
showLabels()
-
Show all labels
cercalia.Label
from markers painted on the map -
showLoading()
-
Shows "Loading..."
-
showMarkers(markers, show)
-
Show the markers painted on the map. This function is usefull when some or all markers are hidden.
Name Type Description markers
cercalia.Marker | Array.<cercalia.Marker> show
boolean