addMouseCoordinates | R Documentation |
This function adds a box displaying the current cursor location (latitude, longitude and zoom level) at the top of a rendered mapview or leaflet map. In case of mapview, this is automatically added. NOTE: The information will only render once a mouse movement has happened on the map.
addMouseCoordinates(map, epsg = NULL, proj4string = NULL, native.crs = FALSE)
removeMouseCoordinates(map)
clip2sfc(x, clipboard = TRUE)
map |
a mapview or leaflet object. |
epsg |
the epsg string to be shown. |
proj4string |
the proj4string to be shown. |
native.crs |
logical. whether to use the native crs in the coordinates box. |
x |
a charcter string with valid longitude and latitude values. Order
matters! If missing and |
clipboard |
whether to read contents from the clipboard. Default is
|
If style is set to "detailed", the following information will be displayed:
x: x-position of the mouse cursor in projected coordinates
y: y-position of the mouse cursor in projected coordinates
epsg: the epsg code of the coordinate reference system of the map
proj4: the proj4 definition of the coordinate reference system of the map
lat: latitude position of the mouse cursor
lon: longitude position of the mouse cursor
zoom: the current zoom level
By default, only 'lat', 'lon' and 'zoom' are shown. To show the details about epsg, proj4 press and hold 'Ctrl' and move the mouse. 'Ctrl' + click will copy the current contents of the box/strip at the top of the map to the clipboard, though currently only copying of 'lon', 'lat' and 'zoom' are supported, not 'epsg' and 'proj4' as these do not change with pan and zoom.
removeMouseCoordinates()
: remove mouse coordinates information from a map
clip2sfc()
: convert mouse coordinates from clipboard to sfc
library(leaflet)
leaflet() %>%
addProviderTiles("OpenStreetMap") # without mouse position info
m = leaflet() %>%
addProviderTiles("OpenStreetMap") %>%
addMouseCoordinates()
m
removeMouseCoordinates(m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.