Constructor
new Map2D(target, options)
Parameters:
Name | Type | Description |
---|---|---|
target |
string/HTMLElement | id or HTMLElement |
options |
Object | options object |
- Source:
Methods
addLayer(layer)
Generic Add Layer method. Only adds a layer if the map crs code matches
Parameters:
Name | Type | Description |
---|---|---|
layer |
Layer |
- Source:
appendTo(target, position)
Append the map to a target element.
{@code target} can be an "#id" with with or without a hash in the beginning
or an instance of HTMLElement.
Parameters:
Name | Type | Description |
---|---|---|
target |
string | HTMLElement | id or HTMLElement |
position |
string | HTMLElement | (optional, default=beforeend) beforebegin, afterbegin, beforeend, afterend |
- Source:
closePopup()
Close the currently opened popup
- Source:
dispose()
remove the map instance
- Source:
fitBounds(bbox)
Parameters:
Name | Type | Description |
---|---|---|
bbox |
object | { min: {x, y}, max: {x, y}, crs: "CRS:84" } |
- Source:
getBounds() → {object}
Get the current bounds of the map
- Source:
Returns:
{ min: {x, y}, max: {x, y}, crs: "CRS:84" }
- Type
- object
getFeatureInfoOptions(lat, lng)
Build a bounding box from a click location
for getFeatureInfo requests
Parameters:
Name | Type | Description |
---|---|---|
lat |
number | click lat |
lng |
number | click lng |
- Source:
getMaxZoom() → {number}
Wrapper method to get the max zoom of the map
- Source:
Returns:
max zoom level
- Type
- number
getMinZoom() → {number}
Wrapper method to get the min zoom of the map
- Source:
Returns:
min zoom level
- Type
- number
getOptions() → {object}
Get the current map options
- Source:
Returns:
options
- Type
- object
getZoom() → {number}
Wrapper method to get the current zoom of the map
- Source:
Returns:
zoom level
- Type
- number
initMap_()
initialize div containers
- Source:
removeLayer(layer)
Generic Remove Layer method
Parameters:
Name | Type | Description |
---|---|---|
layer |
Layer |
- Source:
resetViewport()
reset viewport of the map.
necessary after resizing the div or switching the projection
- Source:
setActiveArea(className, centerMap)
sets the active area div
Parameters:
Name | Type | Description |
---|---|---|
className |
string | css class name |
centerMap |
boolean | automatically re-center the map (default = false) |
- Source:
setBaseLayer(layer, crs)
Set baselayer and projection. Crs and layer need to match.
Either option can be ommited, if the current baselayer/crs
matches the changed property
Parameters:
Name | Type | Description |
---|---|---|
layer |
Layer | |
crs |
string |
- Source:
setMaxBounds(bbox)
Parameters:
Name | Type | Description |
---|---|---|
bbox |
object | { min: {x, y}, max: {x, y}, crs: "CRS:84" } |
- Source:
setView(latLng, zoom)
Parameters:
Name | Type | Description |
---|---|---|
latLng |
Array.<number> | |
zoom |
number |
- Source:
showPopup(lat, lng, content)
Wrapper method for showing a popup on the map
Parameters:
Name | Type | Description |
---|---|---|
lat |
number | |
lng |
number | |
content |
string |
- Source:
startDrawing(shape)
Start drawing shapes on the map
Uses Leaflet.Draw version 0.4.12. Version 0.4.14 has a bug in the edit mode
https://github.com/Leaflet/Leaflet.draw/issues/804
Parameters:
Name | Type | Description |
---|---|---|
shape |
string | rectangle, polygon, line, point |
- Source:
stopDrawing()
Abort drawing
- Source:
zoomIn()
Wrapper method to zoom in one step
- Source:
zoomOut()
Wrapper method to zoom out one step
- Source: