addMouseCoordinates: Add mouse coordinate information at top of map.

Description Usage Arguments Details Functions Examples

View source: R/mousecoords.R

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

1
2
3
4
5
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(leaflet)

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

m

removeMouseCoordinates(m)

leafem documentation built on July 26, 2020, 5:06 p.m.