Package leafem provides a few extra
add* functions for use with leaflet (and mapview).
addMouseCoordinates- add a box with mouse position, projection information and zoom level information
addLogo- add images to maps
addHomeButton- add zoom-to button to a map
addFeatures- add features to a map, regardless of features type unresposnive
Here are some examples:
let’s us add mouse position information along with detailed information about the layer’s projection and zoom level information. By default, only
zoom are shown. To also show info on the
epsg code and the
proj4string press and hold Ctrl and move the mouse.
addMouseCoordinates also allows us to copy the info about the current mouse position to the clipboard by holding the Ctrl and left-clicking on the map.
can be used to add logos (or any type of image really) to a map
offset.y together with
position give control about image placement. See
?addLogo for details
is a type agnostic
add* function which will call the approprate
leaflet::add* function based on the provided feature type (points, lines, polygons). It is currently defined for handling objects from packages
sf objects, in addition to the standard feature types
MULTIPOLYGON it can also handle features of type
sfc_GEOMETRY which are a collection of mixed types.
The standard styling arguments for
leaflet::add* functions can be used just like in the original
library(leafem) leaflet() %>% addTiles() %>% leafem::addFeatures(franconia, weight = 1, fillColor = "grey", color = "black", opacity = 1, fillOpacity = 0.6)