rOpenSpain / mapSpain

R package with the administrative boundaries of Spain, including CCAA, provinces and municipalities
https://ropenspain.github.io/mapSpain/
GNU General Public License v3.0
42 stars 3 forks source link

Does Leaflet-providersESP work with mapview? #82

Closed fgoerlich closed 1 year ago

fgoerlich commented 1 year ago

I find that Leaflet-providersESP does not work with mapview and the map.types option. Is that correct?

If I run the Earthquakes in Tenerife example I get the expected result, which are shown on the web.

But using mapview does not work. Even if is does work with standard Leaflet-providers

library(mapview)
mapview(Tenerife.leaf)

mapview(Tenerife.leaf, map.type = "OpenTopoMap")

mapview(Tenerife.leaf, map.type = "IDErioja")

Created on 2022-11-10 with reprex v2.0.2

dieghernan commented 1 year ago

I am not sure that mapview alllows to add providers other than the already included in https://leaflet-extras.github.io/leaflet-providers/preview/.

However, you can try this hack as provided in https://mhweber.github.io/2018/11/09/adding-wms-basemap-in-r-with-mapview/:


library(mapSpain)

Tenerife.leaf <-
  esp_get_nuts(
    region = "Tenerife",
    epsg = 4326,
    moveCAN = FALSE
  )

library(mapview)
library(leaflet)

m <- mapview(Tenerife.leaf) 

# Hack: https://mhweber.github.io/2018/11/09/adding-wms-basemap-in-r-with-mapview/
m@map <- m@map %>%
  addProviderEspTiles("Geofisica.Terremotos365dias",
                      group = "Earthquakes"
  )

m

image

dieghernan commented 1 year ago

See also https://github.com/r-spatial/mapview/issues/347 where the same hack is presented