Skip to content

Commit 6095d91

Browse files
author
Stefan Kuethe
committed
Add MVT layer
1 parent e5efcf1 commit 6095d91

File tree

23 files changed

+243
-97
lines changed

23 files changed

+243
-97
lines changed

docs/concepts/controls.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Controls are user interface elements that you can add to your map:
2+
3+
```python
4+
-8<-- "concepts/controls.py"
5+
```
6+
7+
> See [Controls API](../../api/controls/)

docs/concepts/geopandas.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# GeoPandas
2+
3+
Python-OpenLayers shipes with a [GeoPandas](https://geopandas.org/) extension:
4+
5+
```python
6+
-8<-- "concepts/geopandas.py"
7+
```

docs/concepts/layers.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Layers and sources
2+
3+
Sources and layers are used to display _raster_ or _vector_ data on your map.
4+
5+
## Sources
6+
7+
Sources state which data the map should display.
8+
9+
```python
10+
-8<-- "concepts/sources.py"
11+
```
12+
13+
> See [Sources API](../../api/layers/)
14+
15+
## Layers
16+
17+
A layer defines how a source is displayed on the map:
18+
19+
```python
20+
-8<-- "concepts/layers.py"
21+
```
22+
23+
> See [Layers API](../../api/layers/)
24+
25+
## Styles
26+
27+
...

docs/concepts/map.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@ The [Map](../../api/map/#openlayers.Map) is the core component of your visualiza
66
-8<-- "concepts/basic_map.py"
77
```
88

9-
## View
9+
## View state
1010

11-
The view state of the map ...
11+
Properties such as _center_, _zoom level_ and _projection_ are managed by the [View](../../api/map/#openlayers.view.View) instance:
12+
13+
```python
14+
-8<-- "concepts/view.py"
15+
```
1216

1317
## Basemaps
1418

15-
> See [BasemapLayer](../../api/basemaps/#openlayers.Basemaps.BasemapLayer)
19+
A basemap in openlayers consists of one or more layers from your layer stack:
20+
21+
```python
22+
-8<-- "concepts/basemaps.py"
23+
```
24+
25+
> See [BasemapLayer API](../../api/basemaps/#openlayers.Basemaps.BasemapLayer)
26+
27+
If you hand over an empty layer stack to your map, a blank background is displayed:
28+
29+
```python
30+
m = ol.Map(layers=[])
31+
```

docs/examples/concepts/basemaps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import openlayers as ol
2+
3+
# Use OSM basemap
4+
m = ol.Map(layers=[ol.BasemapLayer.osm()])
5+
6+
# Use a CartoDB basemap
7+
m = ol.Map(layers=[ol.BasemapLayer.carto()])

docs/examples/concepts/basic_map.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@
55

66
# Add components after initialization
77
m.add_control(ol.FullScreenControl())
8-
9-
# m.add_view_call("setZoom", 5)
10-
m.set_zoom(12)
11-
m.set_center(lonlat=(-122.4, 37.74))
12-
m.save()

docs/examples/concepts/controls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import openlayers as ol
2+
3+
# Add controls during initialization
4+
m = ol.Map(controls=[ol.ZoomSliderControl(), ol.OverviewMapControl()])
5+
6+
# Add components after initialization
7+
m.add_control(ol.ScaleLineControl(units="degrees"))

docs/examples/concepts/geopandas.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import openlayers as ol
2+
from openlayers.geopandas import GeoDataFrame
3+
4+
data = "https://openlayers.org/en/latest/examples/data/geojson/roads-seoul.geojson"
5+
6+
m = GeoDataFrame.from_file(data).ol.explore(tooltip=True)
7+
m.add_control(ol.ScaleLineControl())

docs/examples/concepts/layers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import openlayers as ol
2+
3+
data = "https://openlayers.org/en/latest/examples/data/geojson/roads-seoul.geojson"
4+
5+
geojson_layer = ol.VectorLayer(
6+
id="roads",
7+
source=ol.VectorSource(url=data),
8+
fit_bounds=True,
9+
)
10+
11+
12+
m = ol.Map(
13+
ol.View(rotation=3.14 / 8),
14+
layers=[ol.BasemapLayer.carto(), geojson_layer]
15+
)
16+
m.add_default_tooltip()

docs/examples/concepts/sources.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import openlayers as ol
2+
3+
geojson = "https://openlayers.org/en/latest/examples/data/geojson/roads-seoul.geojson"
4+
geotiff = "https://s2downloads.eox.at/demo/EOxCloudless/2020/rgbnir/s2cloudless2020-16bits_sinlge-file_z0-4.tif"
5+
pmtiles = "https://r2-public.protomaps.com/protomaps-sample-datasets/nz-buildings-v3.pmtiles"
6+
7+
geojson_source = ol.VectorSource(
8+
url=geojson
9+
)
10+
11+
geotiff_source = ol.GeoTIFFSource(
12+
sources=[{"url": geotiff}]
13+
)
14+
15+
pmtiles_source = ol.PMTilesVectorSource(
16+
url=pmtiles,
17+
attributions=["© Land Information New Zealand"]
18+
)

0 commit comments

Comments
 (0)