[R-sig-Geo] mapview with custom tiles

Tim Appelhans tim.appelhans at gmail.com
Wed Sep 21 15:39:15 CEST 2016


Marcel,
from my point of view the question is why would you want to use mapview 
with custom tiles?

If the answer to this is that you want to create a final presentation 
grade map including some of the features that mapview provides by 
default (i.e. zoom-to-layer button, attribute table popup, mouse 
coordinates, scaleBar), you can do so by adding all these components to 
your custom map:

library(mapview)
library(raster)

leaflet() %>%
   addTiles(urlTemplate = 'http://localhost:8000/tiles8/{z}/{x}/{y}.png',
            options = tileOptions(minZoom = 2, maxZoom = 8, tms = TRUE)) %>%
   addPolygons(data = gadmCHE, popup = popupTable(gadmCHE),
               label = row.names(gadmCHE)) %>%
   addHomeButton(extent(gadmCHE), layer.name = "gadmCHE") %>%
   addMouseCoordinates() %>%
   addScaleBar(position = "bottomleft")

or simply

leaflet() %>%
   addTiles(urlTemplate = 'http://localhost:8000/tiles8/{z}/{x}/{y}.png',
            options = tileOptions(minZoom = 2, maxZoom = 8, tms = TRUE)) +
   gadmCHE

which will mimic mapview feel and look even more.

If, on the other hand, you need to either plot often using your custom 
tiles or need mapview to first set up your map, then no, this is 
currently not possible. This can, however be made possible but for that 
I would ask you to please file a feature request at

https://github.com/environmentalinformatics-marburg/mapview/issues

HTH
Tim

On 21.09.2016 14:06, Marcel Stadelmann wrote:
> Hello,
>
> Is it possible to use mapview with custom tiles without the predefined basemaps? In leaflet it is possible with the addTiles() function and a url (urlTemplate). It should work something like:
>
> library(mapview)
> mapview(gadmCHE)@map %>% addTiles(urlTemplate = 'http://localhost:8000/tiles8/{z}/{x}/{y}.png',options = tileOptions(minZoom = 2, maxZoom = 8, tms = TRUE))
>
> In this the local computer serves the tiles with SimpleHTTPServer
> $ python -m SimpleHTTPServer 8000
>
> The problem is, that it's not possible to switch off the preconfigured basemaps and those are overwriting my local tiles.
>
> Thanks,
> Marcel
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
Raum 00A08
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/



More information about the R-sig-Geo mailing list