Skip to content

Commit

Permalink
Merge pull request #6 from Kanahiro/pmtiles
Browse files Browse the repository at this point in the history
Pmtiles
  • Loading branch information
Kanahiro authored Aug 6, 2024
2 parents 7fb3bd9 + 104fb86 commit 0e12eed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,30 @@

1. Install the extension
2. open `style.json` in editor
3. open command palette and run `Maplibre: Viewer`
3. open command palette and run `MapLibre: Viewer`
- ![](https://github.com/Kanahiro/maplibre-vscode-extension/blob/main/doc/palette.png?raw=true)
4. Viewer will open in new tab. When edit `style.json`, the viewer will update automatically.
- ![](https://github.com/Kanahiro/maplibre-vscode-extension/blob/main/doc/viewer.png?raw=true)

### Available protocols

- `http://path/to/file`
- `https://path/to/file`
- `pmtiles://path/to/file.pmtiles`

```json
"sources": {
"openmaptiles": {
"type": "vector",
"url": "pmtiles://https://tile.openstreetmap.jp/static/planet-20240729.pmtiles"
},
"takeshima": {
"type": "vector",
"url": "https://tile.openstreetmap.jp/data/takeshima.json"
}
},
```

## attribution

- icon: <https://github.com/maplibre/maplibre.github.io/blob/main/static/img/maplibre%20old%20profile.png>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "MapLibre",
"description": "",
"publisher": "kiguchi",
"version": "0.0.6",
"version": "0.0.7",
"engines": {
"vscode": "^1.92.0"
},
Expand Down
4 changes: 2 additions & 2 deletions sample/bright.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"sources": {
"openmaptiles": {
"type": "vector",
"url": "https://tile.openstreetmap.jp/data/planet.json"
"url": "pmtiles://https://tile.openstreetmap.jp/static/planet-20240729.pmtiles"
},
"takeshima": {
"type": "vector",
Expand Down Expand Up @@ -48,7 +48,7 @@
"visibility": "visible"
},
"paint": {
"fill-color": "#fff",
"fill-color": "#ffff00",
"fill-opacity": {
"base": 1,
"stops": [
Expand Down
4 changes: 4 additions & 0 deletions src/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ const createWebview = () => {
href="https://unpkg.com/[email protected]/dist/maplibre-gl.css"
rel="stylesheet"
/>
<script src="https://unpkg.com/pmtiles@^3.0.0/dist/pmtiles.js"></script>
</head>
<body>
<div id="map" style="height: 100vh">
<div id="error"></div>
</div>
<script>
const protocol = new pmtiles.Protocol();
maplibregl.addProtocol("pmtiles", protocol.tile);
const map = new maplibregl.Map({
container: 'map',
style: {
Expand Down

0 comments on commit 0e12eed

Please sign in to comment.