Skip to content

Commit 2726367

Browse files
committed
Add vector layer examples
1 parent 8a6931c commit 2726367

File tree

16 files changed

+10127
-101
lines changed

16 files changed

+10127
-101
lines changed
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+
topojson_layer = ol.VectorLayer(
6+
source=ol.VectorSource(
7+
url=data,
8+
format=ol.formats.GeoJSON()
9+
),
10+
style=ol.FlatStyle(fill_color="rgba(255,210,120,0.5)", stroke_color="green", stroke_width=3, circle_radius=5)
11+
)
12+
13+
m = ol.Map(layers=[ol.BasemapLayer.carto()])
14+
m.add_layer(topojson_layer)
15+
m.add_tooltip()
16+
m.save("/tmp/ol-example.html")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import openlayers as ol
2+
3+
data = "https://openlayers.org/en/latest/examples/data/gpx/fells_loop.gpx"
4+
5+
gpx_layer = ol.VectorLayer(
6+
source=ol.VectorSource(
7+
url=data,
8+
format=ol.formats.GPX()
9+
),
10+
style=ol.FlatStyle(circle_fill_color="red", stroke_color="green", stroke_width=3, circle_radius=5)
11+
)
12+
13+
m = ol.Map()
14+
m.add_layer(gpx_layer)
15+
m.save("/tmp/ol-example.html")
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//kml/states.kml"
4+
5+
kml_layer = ol.VectorLayer(
6+
source=ol.VectorSource(
7+
url=data,
8+
format=ol.formats.KML()
9+
),
10+
# style=ol.FlatStyle(fill_color="rgba(255,210,120,0.5)", stroke_color="green", stroke_width=3, circle_radius=5)
11+
)
12+
13+
m = ol.Map()
14+
m.add_layer(kml_layer)
15+
m.add_tooltip()
16+
m.save("/tmp/ol-example.html")
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/topojson/fr-departments.json"
4+
5+
topojson_layer = ol.VectorLayer(
6+
source=ol.VectorSource(
7+
url=data,
8+
format=ol.formats.TopoJSON()
9+
),
10+
style=ol.FlatStyle(fill_color="rgba(255,210,120,0.5)", stroke_color="green", stroke_width=3, circle_radius=5)
11+
)
12+
13+
m = ol.Map()
14+
m.add_layer(topojson_layer)
15+
m.add_tooltip()
16+
m.save("/tmp/ol-example.html")

0 commit comments

Comments
 (0)