Skip to main content

@mapgear/mapengine > Map

Map interface

The main MapEngine map object

Signature:
export interface Map 

Events

PropertyModifiersTypeDescription
onClickGAEvent<MapClickEventArgs>Triggered when the user clicks on the map
onMoveEndGAEvent<GAEventArgs>Triggered when the map movement is finished
onRightClickGAEvent<MapClickEventArgs>Triggered when the user right clicks on the map
onRotationChangedGAEvent<RotationChangedEventArgs>Triggered when the map is rotated

Properties

PropertyModifiersTypeDescription
ExtentExtentCurrent extent of the map
ProjectionProjectionCurrent projection of the map
RotationnumberCurrent rotation of the map
ZoomnumberCurrent zoom level of the map

Methods

MethodDescription
AddLayer(layer)Add a layer to the map
AddOverlay(overlay, position)Add the overlay to the map
ClearBaselayer()Remove a baselayer from the map
ClearLayers()Remove all layers from the map
ConvertCoordinate(inputProjection, outputProject, coordinate)Converts a coordinate between two projections
CreateLayer(options)Create a new, empty layer
CreateOverlay(element, options)Create a new overlay
EnableRotation(enable)Enable / disable rotation of the map
GetCenter()Get the current center position of the map
GetInternalMapObject()Retrieve the internal mapEngine Object, e.g. the OpenLayers map object or the Leaflet map
GetLayer(layerId)Retrieve a layer by id
RemoveLayer(layer)Remove the specified layer from the map
RemoveOverlay(overlay)Remove the overlay from the map
ResetRotation()Reset the rotation to 0
SetBaselayer(layer)Set a layer as baselayer
SetBounds(bounds)Set the bounds of the map
SetMinMaxZoom(minZoom, maxZoom)Limit the zoom levels
SetMouseWheelZoom(enable)Whether mouse wheel zoom is enabled or disabled
SetRotation(rotation, isRadians)Set the rotation of the map
SetZoomLevel(zoomLevel)Zoom to a specified zoomlevekl
TakeSnapshot()Take a snapshot of the current map element as a base64 data-url with png-encoding
UpdateSize()Refresh the map size in the DOM. Usefull when the DOM resizes and the map doesn't detect it automatically, causing a distorted map.
ZoomIn()Perform zoom in on the map with one level
ZoomOut()Perform zoom out on the map with one level
ZoomToCurrentGeolocation()Zoom to current geolocation, using the location provided by the browser
ZoomToExtent(extent, options)Perform zoom to a specific extent
ZoomToGeometry(geometry, options)Zoom to the extent of a geometry
ZoomToLocation(location)Zoom to the specified location