0

In mapview by default, the mouse cursor and projection information are shown in a box at the top of the map.

How can I hide this information box as it is by default in leaflet?

library(leaflet)
library(mapview)

leaflet(data = breweries) %>%
  addTiles() %>%
  addCircleMarkers()

And second, is there an option to show the basic style as in leaflet?

leaflet(data = breweries) %>%
  addTiles() %>%
  addCircleMarkers() %>%
  addMouseCoordinates(style = "basic")

I've tried to do this like this, but couldn't find a solution:

library(mapview)

m <- mapview(breweries)
m@map <- m@map %>%
  addMouseCoordinates(style = "basic")
m

Thanks for the answer!

MLavoie
  • 9,671
  • 41
  • 36
  • 56
danceb
  • 111
  • 3
  • I don't see anything at the top of the map. Could you add a screenshot of the issue you are describing to your post? – MLavoie Feb 20 '18 at 13:18
  • For a solution to your first question see my answer below. Regarding your second question, may I ask why you want to display the basic information only in your mapview call? – TimSalabim Feb 20 '18 at 19:49

1 Answers1

0

To hide the moseCoordinates div you could use the following function:

removeMouseCoordinates = function(map) {
  if (inherits(map, "mapview")) map = mapview2leaflet(map)

  rc = map$jsHooks$render
  rc_lnlt = lapply(rc, grep, pattern = "lnlt")
  for (i in seq_along(map$jsHooks$render)) {
    map$jsHooks$render[[i]][rc_lnlt[[i]]] = NULL
  }

  return(map)
}
TimSalabim
  • 5,604
  • 1
  • 25
  • 36