protomaps / protomaps-leaflet

Lightweight vector map rendering + labeling and symbology for Leaflet
https://protomaps.com/docs/frontends/leaflet
BSD 3-Clause "New" or "Revised" License
766 stars 43 forks source link

Maplibre example #16

Closed tarngerine closed 3 years ago

tarngerine commented 3 years ago

Hi again! I'm testing perf differences between Maplibre and Leaflet and was curious when you might have time to make a Maplibre example for https://protomaps.com/docs/alternate-renderers

Thanks! Julius

bdon commented 3 years ago

The easiest way to access this right now is creating a bundle on https://protomaps.com/bundles and looking at gl.html in the downloaded ZIP.

This isn't using MapLibre yet until PR 30 at https://github.com/maplibre/maplibre-gl-js/pulls is merged.

I do need to add some other examples around using MapLibre/JSON styles, so let's continue in this new issue I made on another repo: https://github.com/protomaps/protomaps-themes/issues/8

tarngerine commented 3 years ago

oh interesting! i thought it already supported custom tiles

image

but now reading this code i grabbed from online somewhere, it looks like its just for raster. so the missing functionality is support for custom vector tiles (not raster)?

thanks as always for the fast response

bdon commented 3 years ago

The missing functionality is custom Protocol support in MapLibre. The way Mapbox 1.13 and MapLibre 1.14 work is that they must consume a Z/X/Y tile URL (an HTTP web service) for vector or raster tiles

All my examples/tools for protomaps.js work with either a Z/X/Y tile URL like above, or a local PMTiles file hosted on your own computer or an S3-like service. To make that second option, PMTiles work in MapLibre, I currently use my own fork of version 1.13 in the gl.html, but it's hacky. If you want to use Z/X/Y tile urls e.g. api.protomaps.com/tiles/v2/{z}/{x}/{y}.pbf it should work just fine with any version of MapBox GL <=1.13 or MapLibre; I don't have good examples yet but basically you need to work off of this json style: https://github.com/protomaps/protomaps-themes/blob/master/mbgl/base.json

tarngerine commented 3 years ago

oh gotcha, that works great! thanks~

bdon commented 3 years ago

@tarngerine see https://github.com/protomaps/protomaps-themes/issues/8#issuecomment-859597903 for more info on GL styles