Leaflet module methods
In the following functions, mapId
always refers to the unique id of a single map in the GUI, as defined in the Leaflet.createMap
function with the mapId
parameter.
Leaflet.addCircle
Queue a new circle in the shapes layer. When all shapes are added, call flushShapes()
to draw all the shapes at once.
shapeId
is a unique shape id;point
is the center of the circle created withLeaflet.latLng()
;tooltip
is a text showing when clicking on the shape;options
are the Circle polygon options. You should at least set theradius
of the circle.
Leaflet.addGeoJSON
Queue a new GeoJSON shape for future rendering on the map. When all GeoJSON shapes are added, call flushGeoJSON()
to draw all the GeoJSON shapes at once.
mapId
is the id of the map;data
is a list of:id
: a unique id for the shape/zone;points
: a list of points;tooltip
: the HTML content of the tooltip when the user put its mouse over the shape;color
: an HTML hex color, like#ff0000
.
Leaflet.addPolygon
Queue a new polygon in the shapes layer. When all shapes are added, call flushShapes()
to draw all the shapes at once.
shapeId
is a unique shape id;points
is a list of points for the polygon created withLeaflet.latLng()
;tooltip
is a text showing when clicking on the shape;options
are the Leaflet polygon options.
Leaflet.createIcon
Create a new icon for future markers. Icon should be created before initializing the map.
iconId
is a unique id;options
is a list of Leaflet icon options.
Leaflet.createMap
Leaflet.createMap(mapId, step, widgetId, layer = layerURL, height = 512, options = list(), layerOptions = list())
Create a new map widget. This function must be called before entering the GUI containing the map.
- mapId is a unique name you give to the map
- step is the step where the map will be, created with
rpgm.step()
- widgetId is the id of the label widget that will contain the map
- layerURL is the tile layer URL (see TileLayer documentation), and layerOptions are the TileLayer Options.
- options is the map options as defined by the Leaflet map options
Leaflet.fitBounds
Show a specific view on the map.
bounds
is a LatLngBounds created withLeaflet.latLngBounds()
Leaflet.flushGeoJSON
Remove all previous rendered geojson shapes and draw all the queued shapes with addGeoJSON()
.
Leaflet.flushShapes
Remove all previous rendered simple shapes and draw all the queued shapes with addCircle()
and addPolygon()
.
Leaflet.hideLoading
Hide the loading state of a map.
Leaflet.latLng
Create a new LatLng object to use where Leaflet LatLng object are used.
Leaflet.latLngBounds
Create a new LatLng object to use where Leaflet LatLngBounds object are used.
Leaflet.marker
Create a new marker to be used with Leaflet.updateMarkers()
.
iconId
is the id of an icon created withLeaflet.createIcon()
;latlng
is the position of the marker created withLeaflet.latLng()
;popup
is the HTML content of the popup when the user click on the marker;options
is a list of Leaflet marker options.
Leaflet.on
Add a new event listener. See the Events section for more information.
Leaflet.off
Remove an existing event listener. See the Events section for more information.
Leaflet.setView
Set the view of the map to a specific point and zoom.
center
is a LatLng point created withLeaflet.latLng()
;zoom
is the wanted zoom level.
Leaflet.setZoom
Set the zoom level of the map.
Leaflet.showLoading
Show the loading state of a map with a spinning animation over the map.
Leaflet.triggerViewEvent
Force the map to send an onDidChangeView
event. Useful to refresh the map view after loading data for example.
Leaflet.updateLegend
Update the content of the legend of the map with content
.
Leaflet.updateMarkers
Remove all existing markers on the map and draw all the markers in the markers
parameter.
mapId
is the id of the map;markers
should be a list of markers created withLeaflet.marker()
.