Skip to content

Commit 34e79cb

Browse files
committed
Add WebGLVectorTileLayer
1 parent 7bf4f88 commit 34e79cb

File tree

7 files changed

+89
-66
lines changed

7 files changed

+89
-66
lines changed

examples/standalone/layers/pmtiles_vector_layer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
url = "https://r2-public.protomaps.com/protomaps-sample-datasets/nz-buildings-v3.pmtiles"
66

7-
pmtiles = ol.layers.VectorTileLayer(
7+
LayerModel = ol.layers.VectorTileLayer
8+
LayerModel = ol.layers.WebGLVectorTileLayer
9+
10+
pmtiles = LayerModel(
811
id="pmtiles",
912
style=default_style(stroke_color="green", stroke_with=3),
1013
source=PMTilesVectorSource(

src/openlayers/js/openlayers.standalone.js

Lines changed: 57 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/layers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
VectorLayer,
99
WebGLTileLayer,
1010
WebGLVectorLayer,
11-
VectorTileLayer
11+
VectorTileLayer,
12+
WebGLVectorTileLayer
1213
)
1314

1415
__all__ = [

src/openlayers/models/layers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ def validate_style(cls, v):
5555

5656
return v
5757

58+
59+
class WebGLVectorTileLayer(VectorTileLayer): ...
60+
61+
5862
class WebGLTileLayer(Layer):
5963
style: dict | None = None
6064

6165

6266
# --- Layer type
63-
LayerT = Union[Layer, TileLayer, VectorLayer, WebGLVectorLayer, WebGLTileLayer, VectorTileLayer]
67+
LayerT = Union[
68+
Layer, TileLayer, VectorLayer, WebGLVectorLayer, WebGLTileLayer, VectorTileLayer
69+
]

srcjs/ipywidget-ts/controls.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ import MousePositionControl from 'ol/control/MousePosition.js';
55
import OverviewMapControl from 'ol/control/OverviewMap.js';
66
import Zoom from 'ol/control/Zoom';
77
import Rotate from 'ol/control/Rotate';
8+
import Attribution from 'ol/control/Attribution.js';
89

910
import { InfoBox } from './custom-controls';
1011

1112
const zoom = new Zoom();
12-
zoom.setProperties({ id: "zoom", type: "zoomControl" });
13+
zoom.setProperties({ id: "zoom", type: "ZoomControl" });
1314

1415
const rotate = new Rotate();
1516
rotate.setProperties({ id: "rotate", type: "RotateControl" });
1617

17-
const defaultControls = [zoom, rotate];
18+
const attribution = new Attribution();
19+
attribution.setProperties({ id: "attribution", type: "AttributionControl" });
20+
21+
const defaultControls = [zoom, rotate, attribution];
1822

1923
const controlCatalog: ControlCatalog = {
2024
ScaleLineControl: ScaleLineControl,
@@ -24,6 +28,7 @@ const controlCatalog: ControlCatalog = {
2428
OverviewMapControl: OverviewMapControl,
2529
ZoomControl: Zoom,
2630
RotateControl: Rotate,
31+
AttributionControl: Attribution,
2732
InfoBox: InfoBox
2833
};
2934

srcjs/ipywidget-ts/layers.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import TileLayer from "ol/layer/Tile";
21
import VectorLayer from "ol/layer/Vector";
2+
import TileLayer from "ol/layer/Tile";
3+
import VectorTileLayer from "ol/layer/VectorTile";
4+
5+
import ImageLayer from "ol/layer/Image";
6+
7+
// WebGL
38
import WebGLVectorLayer from 'ol/layer/WebGLVector.js';
49
import WebGLTileLayer from 'ol/layer/WebGLTile.js';
5-
import VectorTileLayer from "ol/layer/VectorTile";
10+
import WebGLVectorTileLayer from 'ol/layer/WebGLVectorTile.js';
611

712
import VectorSource from "ol/source/Vector";
813

@@ -11,7 +16,9 @@ const layerCatalog: LayerCatalog = {
1116
VectorLayer: VectorLayer,
1217
WebGLVectorLayer: WebGLVectorLayer,
1318
WebGLTileLayer: WebGLTileLayer,
14-
VectorTileLayer: VectorTileLayer
19+
VectorTileLayer: VectorTileLayer,
20+
WebGLVectorTileLayer: WebGLVectorTileLayer,
21+
ImageLayer: ImageLayer
1522
};
1623

1724
// Draw interaction

srcjs/ipywidget-ts/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ type LayerCatalog = {
1414
VectorLayer: any;
1515
WebGLVectorLayer: any;
1616
WebGLTileLayer: any;
17-
VectorTileLayer: any
17+
VectorTileLayer: any;
18+
[key: string]: any;
1819
}
1920
type LayerCatalogKey = keyof LayerCatalog;
2021

0 commit comments

Comments
 (0)