leaflet icon indicating copy to clipboard operation
leaflet copied to clipboard

addTiles does not allow display of self-hosted vector tiles

Open asitemade4u opened this issue 1 year ago • 2 comments

Hi,

[I am unable to include a reprex since the issue relies on a locally self-hosted vector map tile server, pg_tileserv]

  • I have a self-hosted pg_tileservvector map tile server on our network, with a local address (192.168.1.88:7808).
  • I am able to display a map it serves into a leaflet HTML file:
      var map = L.map('map').setView([40.758896,-73.985130],11);
      // Add the vector tile layer to the map from my server
      var vectorServer = "http://192.168.1.88:7808/";
      var vectorLayerId = "ara.prk";
      var vectorUrl = vectorServer + vectorLayerId + "/{z}/{x}/{y}.pbf";
      //...
      var vectorLayer = L.vectorGrid.protobuf(vectorUrl,vectorTileOptions).addTo(map);
  • Of course, I am also able to display all maps it serves using the interface provided by pg_tileserv.
  • However, I am unable display the map using leaflet. Here is the code I am using:
leaflet() %>%
    leaflet::addTiles(urlTemplate = "http://192.168.1.88:7808/ara.prk/{z}/{x}/{y}.pbf") %>%
    leaflet::setView(lng = -73.985130, lat = 40.758896, zoom = 11)

The code yields an empty page.

What am I doing wrong? S.

asitemade4u avatar Mar 04 '24 22:03 asitemade4u

Your tiles are displaying only on Leaflet JS because you are using the vectorGrid plugin to display them, which is capable of displaying .pbf vector tiles. R's addTiles can't work with vector tiles, only raster tiles (.png). However, it would be great to have the ability to display vector tiles in Leaflet R.

kauebraga avatar Feb 20 '25 22:02 kauebraga

@kauebraga Thank you for your answer. Does it mean that it's impossible to work with vector tiles with leaflet. Is there any workaround in your knowledge?

ahmedjoubest avatar May 13 '25 19:05 ahmedjoubest