From 067347cebb51abf768362d1c07efa7aadd082e1e Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Fri, 2 Feb 2024 17:54:46 +0800 Subject: [PATCH] JS v3.0.0 (#346) --- js/README.md | 20 ++++++++++++-------- js/examples/leaflet.html | 2 +- js/examples/maplibre.html | 2 +- js/examples/maplibre_raster_dem.html | 2 +- js/package-lock.json | 4 ++-- js/package.json | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/js/README.md b/js/README.md index 0519865..13c2a39 100644 --- a/js/README.md +++ b/js/README.md @@ -4,21 +4,24 @@ the [PMTiles](https://www.npmjs.com/package/pmtiles) package can be included via ```html - ``` +``` - As an ES6 module: `npm add pmtiles` +All the PMTiles exports are available under the global `pmtiles` variable e.g. `pmtiles.PMTiles`. - ```js - import * as pmtiles from "pmtiles"; - ``` +As an ES6 module: `npm add pmtiles` + +```js +import { PMTiles } from "pmtiles"; +``` ### Leaflet: Raster tileset Example of a raster PMTiles archive displayed in Leaflet: ```js -const p = new pmtiles.PMTiles('example.pmtiles') -pmtiles.leafletRasterLayer(p,{attribution:'© OpenStreetMap'}).addTo(map) +import { PMTiles, leafletRasterLayer } from "pmtiles"; +const p = new PMTiles('example.pmtiles') +leafletRasterLayer(p,{attribution:'© OpenStreetMap'}).addTo(map) ```` [Live example](https://protomaps.github.io/PMTiles/examples/leaflet.html) | [Code](https://github.com/protomaps/PMTiles/blob/main/js/examples/leaflet.html) @@ -32,7 +35,8 @@ See [protomaps-leaflet](https://github.com/protomaps/protomaps-leaflet) Example of a PMTiles archive displayed in MapLibre GL JS: ```js -let protocol = new pmtiles.Protocol(); + import { Protocol } from "pmtiles"; +let protocol = new Protocol(); maplibregl.addProtocol("pmtiles",protocol.tile); var style = { "version": 8, diff --git a/js/examples/leaflet.html b/js/examples/leaflet.html index b00f3f4..3560eb2 100644 --- a/js/examples/leaflet.html +++ b/js/examples/leaflet.html @@ -4,7 +4,7 @@ - +