addMouseCoordinates {leafem}R Documentation

Add mouse coordinate information at top of map.

Description

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.

Usage

addMouseCoordinates(map, epsg = NULL, proj4string = NULL, native.crs = FALSE)

removeMouseCoordinates(map)

clip2sfc(x, clipboard = TRUE)

Arguments

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 = TRUE (the default) contents will be read from the clipboard.

clipboard

whether to read contents from the clipboard. Default is TRUE.

Details

If style is set to "detailed", the following information will be displayed:

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.

Functions

Examples

library(leaflet)

leaflet() %>%
  addProviderTiles("OpenStreetMap") # without mouse position info
m = leaflet() %>%
  addProviderTiles("OpenStreetMap") %>%
  addMouseCoordinates()

m

removeMouseCoordinates(m)


[Package leafem version 0.2.3 Index]