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, style = c("detailed", "basic"), epsg = NULL,
proj4string = NULL, native.crs = FALSE)
a mapview or leaflet object.
whether to show 'detailed' or 'basic' mouse position info. See Details for an explanation.
the epsg string to be shown.
the proj4string to be shown.
logical. whether to use the native crs in the coordinates box.
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
If style is set to "basic", only 'lat', 'lon' and 'zoom' are shown.
# NOT RUN {
library(leaflet)
leaflet() %>% addProviderTiles("OpenStreetMap") # without mouse position info
leaflet() %>%
addProviderTiles("OpenStreetMap") %>%
addMouseCoordinates(style = "basic") # with basic mouse position info
leaflet() %>%
addProviderTiles("OpenStreetMap") %>%
addMouseCoordinates() # with detailed mouse position info
# }
Run the code above in your browser using DataLab