From 40679aa2bd7bd13d2b9bae442c80b05e2b8f2331 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Fri, 28 Oct 2022 18:34:47 +0800 Subject: [PATCH] js docs: add example on line to include library --- js/README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/js/README.md b/js/README.md index 3cddade..e6d38be 100644 --- a/js/README.md +++ b/js/README.md @@ -1,8 +1,16 @@ -the [PMTiles](https://www.npmjs.com/package/pmtiles) package can be included via script tag or ES6 module. +the [PMTiles](https://www.npmjs.com/package/pmtiles) package can be included via script tag or ES6 module: -## Leaflet +```html + + ``` -### Raster tileset + As an ES6 module: `npm add pmtiles` + + ```js + import * as pmtiles from "pmtiles"; + ``` + +### Leaflet: Raster tileset Example of a raster PMTiles archive displayed in Leaflet: @@ -11,10 +19,9 @@ const p = new pmtiles.PMTiles('example.pmtiles') pmtiles.leafletRasterLayer(p,{attribution:'© OpenStreetMap'}).addTo(map) ```` - [Live example](https://protomaps.github.io/PMTiles/examples/leaflet.html) | [Code](https://github.com/protomaps/PMTiles/blob/master/js/examples/leaflet.html) -### Vector tileset +### Leaflet: Vector tileset See [protomaps.js](https://github.com/protomaps/protomaps.js)