JS v3.0.0 (#346)

This commit is contained in:
Brandon Liu
2024-02-02 17:54:46 +08:00
committed by GitHub
parent 7cc025c776
commit 067347cebb
6 changed files with 18 additions and 14 deletions

View File

@@ -6,10 +6,12 @@ the [PMTiles](https://www.npmjs.com/package/pmtiles) package can be included via
<script src="https://unpkg.com/pmtiles@2.5.0/dist/index.js"></script> <script src="https://unpkg.com/pmtiles@2.5.0/dist/index.js"></script>
``` ```
All the PMTiles exports are available under the global `pmtiles` variable e.g. `pmtiles.PMTiles`.
As an ES6 module: `npm add pmtiles` As an ES6 module: `npm add pmtiles`
```js ```js
import * as pmtiles from "pmtiles"; import { PMTiles } from "pmtiles";
``` ```
### Leaflet: Raster tileset ### Leaflet: Raster tileset
@@ -17,8 +19,9 @@ the [PMTiles](https://www.npmjs.com/package/pmtiles) package can be included via
Example of a raster PMTiles archive displayed in Leaflet: Example of a raster PMTiles archive displayed in Leaflet:
```js ```js
const p = new pmtiles.PMTiles('example.pmtiles') import { PMTiles, leafletRasterLayer } from "pmtiles";
pmtiles.leafletRasterLayer(p,{attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a>'}).addTo(map) const p = new PMTiles('example.pmtiles')
leafletRasterLayer(p,{attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a>'}).addTo(map)
```` ````
[Live example](https://protomaps.github.io/PMTiles/examples/leaflet.html) | [Code](https://github.com/protomaps/PMTiles/blob/main/js/examples/leaflet.html) [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: Example of a PMTiles archive displayed in MapLibre GL JS:
```js ```js
let protocol = new pmtiles.Protocol(); import { Protocol } from "pmtiles";
let protocol = new Protocol();
maplibregl.addProtocol("pmtiles",protocol.tile); maplibregl.addProtocol("pmtiles",protocol.tile);
var style = { var style = {
"version": 8, "version": 8,

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.0/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet@1.9.0/dist/leaflet.js"></script>
<script src="https://unpkg.com/pmtiles@3.0.0-alpha.2/dist/index.js"></script> <script src="https://unpkg.com/pmtiles@3.0.0/dist/index.js"></script>
<style> <style>
body, #map { body, #map {
height:100vh; height:100vh;

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.css" crossorigin="anonymous">
<script src="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.js" crossorigin="anonymous"></script> <script src="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/pmtiles@3.0.0-alpha.2/dist/index.js"></script> <script src="https://unpkg.com/pmtiles@3.0.0/dist/index.js"></script>
<style> <style>
body { body {
margin: 0; margin: 0;

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.css" crossorigin="anonymous">
<script src="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.js" crossorigin="anonymous"></script> <script src="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/pmtiles@3.0.0-alpha.2/dist/index.js"></script> <script src="https://unpkg.com/pmtiles@3.0.0/dist/index.js"></script>
<style> <style>
body { body {
margin: 0; margin: 0;

4
js/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "pmtiles", "name": "pmtiles",
"version": "3.0.0-alpha.2", "version": "3.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "pmtiles", "name": "pmtiles",
"version": "3.0.0-alpha.2", "version": "3.0.0",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"@types/leaflet": "^1.9.8", "@types/leaflet": "^1.9.8",

View File

@@ -1,6 +1,6 @@
{ {
"name": "pmtiles", "name": "pmtiles",
"version": "3.0.0-alpha.2", "version": "3.0.0",
"description": "PMTiles archive decoder for browsers", "description": "PMTiles archive decoder for browsers",
"type": "module", "type": "module",
"exports": "./dist/index.mjs", "exports": "./dist/index.mjs",