maptiler / leaflet-maptilersdk

Vector Tiles Basemap plugin for Leaflet - multi-lingual basemaps using MapTiler SDK powered by MapLibre
Other
15 stars 2 forks source link

How can I use Leaflet to display a map from an MBTiles file hosted on my MapTiler server? #9

Open josemanuelorts opened 4 months ago

josemanuelorts commented 4 months ago

I have the following information available on the server:

Embeddable viewer: URL: http://localhost:3650/api/tiles/spain Method: Embedding with iframe Tiles: TileJSON: http://localhost:3650/api/tiles/spain/tiles.json XYZ: http://localhost:3650/api/tiles/spain/{z}/{x}/{y} What steps do I need to take to integrate this map into a Leaflet map using the provided information?"

bolollo commented 4 months ago

Hello @josemanuelorts, First, you should create a map (you probably already have one in the map tab). In the message, you have put the URLs of the tiles, which are the data sources. If you want to consume your map as raster tiles (which is Leaflet's default option), you can see this example https://docs.maptiler.com/leaflet/examples/raster-tiles-in-leaflet-js/ here you would have to change the URL of the L.tileLayer with yours http://localhost:3650/api/maps/YOUR_MAP_ID/{z}/{x}/{y}.png (e.g. http://localhost:3650/api/maps /spain/{z}/{x}/{y}.png) If you want to use vector tiles, use our plugin; here is an example https://docs.maptiler.com/leaflet/examples/vector-tiles-in-leaflet-js/. In this case, in the style parameter, you must place your URL that http://localhost:3650/api/maps/YOUR_MAP_ID/style.json

Saludos