In short: This is about proxy-ing access to OpenMapTiles (OMT) by Apache Http. The proxy works hence the PBF tiles from OMT reach the client. However Leaflet fails to draw the PBF tiles in the map.

Below is the detailed:

I am responsible in providing OMT service in intranet of my organization. An existing & running internal web app (let's say TheApp) that requires login, currently add a new feature showing map with 2 elements: - geoJSON queried from DB - basemap from my OMT

TheApp is PHP running on Apache HTTP on Fedora.


The javascript for showing the map specifies that client should get the OMT tiles directly from my OMT server. The result is just fine: the map shows geoJSON on top of OMT basemap as expected. Below is the diagram. enter image description here


The strategy is changed. The client has no direct access to OMT, and basemap tiles are provided through Apache Http Proxy. The module used in Apache HTTP is mod_proxy. The result is just fine: the map shows geoJSON on top of OMT basemap as expected. Below is the diagram. enter image description here


The strategy is changed again (but the diagram is similar to Phase-2). This is because in Phase-2, any browser can get the OMT tiles through the Reverse-proxy in the Apache HTTP and we don't like it. Now in Phase-3 we decide that only browser that logged-in in TheApp can get the OMT tiles. My colleague (the admin of the Apache HTTP) finds that this requirement can not be achieved by mod_proxy, and hence uses mod_rewrite as suggested by several references. With mod_rewrite he configured that the required resources from OMT (including the PBF tiles) are rewritten to another address.

Now the result is: the mod_rewrite works, as the client re-requests to the specified address, and therefore the client got the PBF tiles. However Leaflet fails to show the PBF tiles.

How to fix this? (Remember, the client got the PBF tiles). Below is the Dev Console of Chrome.enter image description here

I suspect that Leaflet can not show the PBF tiles on map because under mod_rewrite the expected identifier of each PBF tile can not be understood by Leaflet. The Z/X/Y naming is still kept in the rewrite result, though.

  • Your question says Leaflet, but the stack trace says mapbox-gl. Please double-check that, as they are not the same. – IvanSanchez Nov 10 '18 at 23:52
  • The unimplemented type: 4 leads me to think that the file received by the browser is not a valid vector tile. Please check as well. – IvanSanchez Nov 10 '18 at 23:53
  • @IvanSanchez The reason why there's mapbox-gl.js is because Leaflet doesn't support vector tiles by default. Therefore Leaflet needs a plugin, that -I believe- is based on Mapbox. Am pretty sure you are aware of this. Here is the reference. It requires the mapbox-gl.js. – Rino Nov 11 '18 at 12:06
  • @IvanSanchez. I am glad that you noticed the Chrome console error saying unimplemented type. As for the PBF tiles that reach the browser but doesn't get displayed at all by Leaflet (in the Phase-3 above), I got an impression that they are identical to the corresponding PBF in my Phase-2 or 1. I confirm this by comparing files of the same Z/X/Y, looking at the file size, and the content of PBF as shown by Notepad++. Yet in my Phase-3, Leaflet does not show these PBFs. Well, for me the PBFs in my Phase-3 are valid, but apparently Leaflet does not agree to this. :) So did i miss something? – Rino Nov 11 '18 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.