-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for PMTiles * Fix yarnpkg error * Fix package.json * Remove maplibre-gl-leaflet * Update package * Fix linter issue * Fix linter issue * Change layer view * Incorporate jtmiclat code * Add PMTiles notebook
- Loading branch information
Showing
6 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Set up for JupyterLite\n", | ||
"try:\n", | ||
" import piplite\n", | ||
" await piplite.install('ipyleaflet')\n", | ||
"except ImportError:\n", | ||
" pass" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ipyleaflet import Map, basemaps, PMTilesLayer" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m = Map(center=[52.963529, 4.776306], zoom=7, basemap=basemaps.CartoDB.DarkMatter, scroll_wheel_zoom=True)\n", | ||
"m.layout.height = '600px'\n", | ||
"\n", | ||
"vl = PMTilesLayer(url=\"https://storage.googleapis.com/ahp-research/overture/pmtiles/overture.pmtiles\", \n", | ||
" style = {\n", | ||
" \"layers\": [\n", | ||
" {\n", | ||
" \"id\": \"admins\",\n", | ||
" \"source\": \"example_source\",\n", | ||
" \"source-layer\": \"admins\",\n", | ||
" \"type\": \"fill\",\n", | ||
" \"paint\": {\"fill-color\": \"#BDD3C7\", \"fill-opacity\": 0.1},\n", | ||
" },\n", | ||
" {\n", | ||
" \"id\": \"buildings\",\n", | ||
" \"source\": \"example_source\",\n", | ||
" \"source-layer\": \"buildings\",\n", | ||
" \"type\": \"fill\",\n", | ||
" \"paint\": {\"fill-color\": \"#FFFFB3\", \"fill-opacity\": 0.5},\n", | ||
" },\n", | ||
" {\n", | ||
" \"id\": \"places\",\n", | ||
" \"source\": \"example_source\",\n", | ||
" \"source-layer\": \"places\",\n", | ||
" \"type\": \"fill\",\n", | ||
" \"paint\": {\"fill-color\": \"#BEBADA\", \"fill-opacity\": 0.5},\n", | ||
" },\n", | ||
" {\n", | ||
" \"id\": \"roads\",\n", | ||
" \"source\": \"example_source\",\n", | ||
" \"source-layer\": \"roads\",\n", | ||
" \"type\": \"line\",\n", | ||
" \"paint\": {\"line-color\": \"#FB8072\"},\n", | ||
" },\n", | ||
" ],\n", | ||
" })\n", | ||
"m.add(vl)\n", | ||
"m" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
const layer = require('./Layer.js'); | ||
const protomapsL = require('protomaps-leaflet'); | ||
|
||
export class LeafletPMTilesLayerModel extends layer.LeafletLayerModel { | ||
defaults() { | ||
return { | ||
...super.defaults(), | ||
_view_name: 'LeafletPMTilesLayerView', | ||
_model_name: 'LeafletPMTilesLayerModel', | ||
url: '', | ||
attribution: '', | ||
style: {}, | ||
}; | ||
} | ||
} | ||
|
||
export class LeafletPMTilesLayerView extends layer.LeafletLayerView { | ||
create_obj() { | ||
var options = { | ||
...this.get_options(), | ||
url: this.model.get('url'), | ||
...protomapsL.json_style(this.model.get('style')), | ||
}; | ||
this.obj = protomapsL.leafletLayer(options); | ||
} | ||
|
||
model_events() { | ||
super.model_events(); | ||
this.listenTo( | ||
this.model, | ||
'change:url', | ||
function () { | ||
this.obj.setUrl(this.model.get('url')); | ||
}, | ||
this | ||
); | ||
} | ||
|
||
handle_message(content) { | ||
if (content.msg == 'add_inspector') { | ||
this.obj.addInspector(this.map_view.obj); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters