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.
shapeIdis a unique shape id;pointis the center of the circle created withLeaflet.latLng();tooltipis a text showing when clicking on the shape;optionsare the Circle polygon options. You should at least set theradiusof 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.
mapIdis the id of the map;datais 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.
shapeIdis a unique shape id;pointsis a list of points for the polygon created withLeaflet.latLng();tooltipis a text showing when clicking on the shape;optionsare the Leaflet polygon options.
Leaflet.createIcon
Create a new icon for future markers. Icon should be created before initializing the map.
iconIdis a unique id;optionsis 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.
boundsis 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().
iconIdis the id of an icon created withLeaflet.createIcon();latlngis the position of the marker created withLeaflet.latLng();popupis the HTML content of the popup when the user click on the marker;optionsis 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.
centeris a LatLng point created withLeaflet.latLng();zoomis 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.
mapIdis the id of the map;markersshould be a list of markers created withLeaflet.marker().