Skip to content

Commit 5b31700

Browse files
Merge pull request #35 from geoadmin/feat-PB-1931-codepen-examples
PB-1931: update Codepens and migrate API3 example page
2 parents 01e5736 + 33562d9 commit 5b31700

6 files changed

Lines changed: 63 additions & 36 deletions

File tree

docs/3d-tiles.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ example='{
6464

6565
## Example: Cesium
6666

67-
An example Cesium application using terrain tiles, 3D buildings and WMTS.
67+
An example of a Cesium application using terrain tiles, 3D buildings and a WMTS layer.
6868

69-
<iframe height="600" style="width: 100%;" scrolling="no" title="Geoadmin Terrain, Buildings and WMTS CesiumJS integration" src="https://codepen.io/geoadmin/embed/zBEYGE?default-tab=js%2Cresult&editable=true&zoom=0.5" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
69+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/NPGLwVO?default-tab=js%2Cresult&editable=true&zoom=0.5" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
7070
</iframe>

docs/embed-in-an-iframe.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
You can embed an interactive version of the [map viewer](https://map.geo.admin.ch/) into your webpage using an HTML iframe, as shown below:
44

5-
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2600988.46,1197433.4&z=8&topic=ech&layers=&bgLayer=ch.swisstopo.pixelkarte-farbe&featureInfo=default" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
5+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2600988.46,1197433.4&z=8&topic=ech&layers=&bgLayer=ch.swisstopo.pixelkarte-farbe&featureInfo=default" style="border: 0;width: 100%;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
66

77
The following expands on the introduction given in the [Web Integration: iFrame](https://www.geo.admin.ch/de/web-integration-iframe/) page.
88

@@ -21,7 +21,11 @@ To add a legend of a specific layer to your embedded map viewer:
2121
Here is an example:
2222

2323
```html
24-
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2675475,1229326.76&z=6&topic=ech&layers=ch.bfe.grundwasserwaermenutzungspotential&bgLayer=ch.swisstopo.pixelkarte-grau" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
24+
<iframe
25+
src="https://map.geo.admin.ch/#/embed?lang=en&center=2675475,1229326.76&z=6&topic=ech&layers=ch.bfe.grundwasserwaermenutzungspotential&bgLayer=ch.swisstopo.pixelkarte-grau"
26+
style="border: 0;width: 100%;height: 300px;max-width: 100%;max-height: 100%;"
27+
allow="geolocation"
28+
></iframe>
2529
<b>Legend</b>
2630
<p>
2731
<img
@@ -33,9 +37,10 @@ Here is an example:
3337

3438
which looks like this in the final webpage:
3539

36-
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2675475,1229326.76&z=6&topic=ech&layers=ch.bfe.grundwasserwaermenutzungspotential&bgLayer=ch.swisstopo.pixelkarte-grau" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
40+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2675475,1229326.76&z=6&topic=ech&layers=ch.bfe.grundwasserwaermenutzungspotential&bgLayer=ch.swisstopo.pixelkarte-grau" style="border: 0;width: 100%;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
3741

3842
<b>Legend</b>
43+
3944
<p>
4045
<img
4146
src="https://api3.geo.admin.ch/static/images/legends/ch.bfe.grundwasserwaermenutzungspotential_en.png"
@@ -55,7 +60,7 @@ To add custom elements like POIs, paths, and text on top of the map viewer:
5560

5661
For example, to get to a result that looks like this:
5762

58-
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2685959.53,1248777.78&z=9.63&topic=ech&layers=KML%7Chttps://cms.geo.admin.ch/www.geo.admin.ch/kml/zoo.kml&bgLayer=ch.swisstopo.pixelkarte-grau&featureInfo=default" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
63+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2685959.53,1248777.78&z=9.63&topic=ech&layers=KML%7Chttps://cms.geo.admin.ch/www.geo.admin.ch/kml/zoo.kml&bgLayer=ch.swisstopo.pixelkarte-grau&featureInfo=default" style="border: 0;width: 100%;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
5964

6065
follow these steps:
6166

@@ -65,20 +70,21 @@ follow these steps:
6570

6671
```html
6772
<iframe
68-
src="https://map.geo.admin.ch/#/embed?
73+
src="https://map.geo.admin.ch/#/embed?
6974
lang=en&
7075
center=2685959.53,1248777.78&
7176
z=9.63&
7277
topic=ech&
7378
layers=KML%7Chttps://cms.geo.admin.ch/www.geo.admin.ch/kml/zoo.kml
7479
&bgLayer=ch.swisstopo.pixelkarte-grau
7580
&featureInfo=default"
76-
style="border: 0;
77-
width: 400px;
81+
style="border: 0;
82+
width: 100%;
7883
height: 300px;
7984
max-width: 100%;
8085
max-height: 100%;"
81-
allow="geolocation">
86+
allow="geolocation"
87+
>
8288
</iframe>
8389
```
8490

@@ -95,7 +101,7 @@ For example, to center the map on the address "Holzikofenweg 36, 3007 Bern":
95101
src="https://map.geo.admin.ch/#/embed?
96102
&swisssearch=Holzikofenweg 36, 3007 Bern"
97103
style="border: 0;
98-
width: 400px;
104+
width: 100%;
99105
height: 300px;
100106
max-width: 100%;
101107
max-height: 100%;"
@@ -106,14 +112,15 @@ You would pass the address to the `swisssearch` parameter in an iframe like this
106112

107113
```html
108114
<iframe
109-
src="https://map.geo.admin.ch/#/embed?
115+
src="https://map.geo.admin.ch/#/embed?
110116
&swisssearch=Holzikofenweg 36, 3007 Bern"
111-
style="border: 0;
112-
width: 400px;
117+
style="border: 0;
118+
width: 100%;
113119
height: 300px;
114120
max-width: 100%;
115121
max-height: 100%;"
116-
allow="geolocation">
122+
allow="geolocation"
123+
>
117124
</iframe>
118125
```
119126

@@ -124,7 +131,7 @@ For example, if you search for the ambiguous "Holzikofenweg, 3007 Bern" without
124131
src="https://map.geo.admin.ch/#/embed?
125132
&swisssearch=Holzikofenweg, 3007 Bern"
126133
style="border: 0;
127-
width: 400px;
134+
width: 100%;
128135
height: 300px;
129136
max-width: 100%;
130137
max-height: 100%;"
@@ -135,15 +142,16 @@ Appending `swisssearch_autoselect=true` centers the map on the first search resu
135142

136143
```html
137144
<iframe
138-
src="https://map.geo.admin.ch/#/embed?
145+
src="https://map.geo.admin.ch/#/embed?
139146
&swisssearch=Holzikofenweg, 3007 Bern
140147
&swisssearch_autoselect=true"
141-
style="border: 0;
142-
width: 400px;
148+
style="border: 0;
149+
width: 100%;
143150
height: 300px;
144151
max-width: 100%;
145152
max-height: 100%;"
146-
allow="geolocation">
153+
allow="geolocation"
154+
>
147155
</iframe>
148156
```
149157

@@ -154,7 +162,7 @@ The corresponding iframe:
154162
&swisssearch=Holzikofenweg, 3007 Bern
155163
&swisssearch_autoselect=true"
156164
style="border: 0;
157-
width: 400px;
165+
width: 100%;
158166
height: 300px;
159167
max-width: 100%;
160168
max-height: 100%;"
@@ -167,25 +175,35 @@ To embed the map viewer with the search bar and other menus, replace the `#/embe
167175

168176
In an example:
169177

170-
<iframe src="https://map.geo.admin.ch/#/map?lang=en&center=2675475,1229326.76&z=6&bgLayer=ch.swisstopo.pixelkarte-farbe" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
178+
<iframe src="https://map.geo.admin.ch/#/map?lang=en&center=2675475,1229326.76&z=6&bgLayer=ch.swisstopo.pixelkarte-farbe" style="border: 0;width: 100%;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
171179

172180
This is represented by an iframe like:
173181

174182
```html
175183
<iframe
176-
src="https://map.geo.admin.ch/#/map?
184+
src="https://map.geo.admin.ch/#/map?
177185
lang=en&
178186
center=2675475,1229326.76&
179187
z=6&
180188
bgLayer=ch.swisstopo.pixelkarte-farbe"
181-
style="border: 0;
182-
width: 400px;
189+
style="border: 0;
190+
width: 100%;
183191
height: 300px;
184192
max-width: 100%;
185193
max-height: 100%;"
186-
allow="geolocation"></iframe>
194+
allow="geolocation"
195+
></iframe>
187196
```
188197

189198
:::tip
190199
To ensure proper geolocation functionality, explicitly enable geolocation with `allow="geolocation"` to avoid issues in certain web browsers.
191200
:::
201+
202+
## Example: Accessing Feature Info from an Embedded Map
203+
204+
This example demonstrates how to enable interaction between an embedded map and other elements on your webpage.
205+
When a user clicks on a supported feature (currently from KML or GeoJSON layers), the map sends a `message` event to the parent page using the postMessage API.
206+
The event is then captured by the parent page and used to display feature information outside the iframe.
207+
208+
<iframe height="600" style="width: 100%;" scrolling="no" title="Basic iframe" src="https://codepen.io/geoadmin/embed/zxvyMBp?default-tab=none%2Cresult" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
209+
</iframe>

docs/terrain-service.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ example='{
5353

5454
## Example: Cesium
5555

56-
An example Cesium application using terrain tiles, 3D buildings and WMTS.
56+
An example of a Cesium application using terrain tiles, 3D buildings and a WMTS layer.
5757

58-
<iframe height="600" style="width: 100%;" scrolling="no" title="Geoadmin Terrain, Buildings and WMTS CesiumJS integration" src="https://codepen.io/geoadmin/embed/zBEYGE?default-tab=js%2Cresult&editable=true&zoom=0.5" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
58+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/NPGLwVO?default-tab=js%2Cresult&editable=true&zoom=0.5" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
5959
</iframe>

docs/wms.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,10 @@ The output image:
145145
- [MapInfo](http://www.twiav.nl/files/TWIAV_TIP_MI002.pdf)
146146
- [Quantum GIS](http://www.qgis.org/en/docs/index.html)
147147
- [Exemple 1 - Mappetizer](http://www.mappetizer.de/de/beispiele/wms_bafu_suisse/index.html)
148+
149+
## Example: OpenLayers
150+
151+
This OpenLayers example shows how the CadastralWebMap appears differently when loaded using a WMTS compared to a tiled WMS.
152+
153+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/ogjMOay?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
154+
</iframe>

docs/wmts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ example='{
152152

153153
## Examples: OpenLayers
154154

155-
An OpenLayers3 example showing the Cadastralwebmap as WMTS and Tiled WMS
155+
This OpenLayers example shows how the CadastralWebMap appears differently when loaded using a WMTS compared to a tiled WMS.
156156

157-
<iframe height="600" style="width: 100%;" scrolling="no" title="WMTS in (EPSG:21781) and WMS (EPSG:21781)" src="https://codepen.io/geoadmin/embed/xVKLdV?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
157+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/ogjMOay?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
158158
</iframe>
159159

160160
<br/>
161161

162162
Using geo.admin.ch WMTS tiles in the new LV95 frame (EPSG:2056).
163163

164-
<iframe height="600" style="width: 100%;" scrolling="no" title="WMTS layer (EPSG:2056)" src="https://codepen.io/geoadmin/embed/GZKEam?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
164+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/xbwJoMO?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
165165
</iframe>

docs/xyz.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ To check the latest change of any layer, use the [Cache Update](/docs/wmts#cache
4040

4141
## Examples
4242

43-
Fetch a single tile:
43+
### Get a Single Tile
44+
45+
Fetch a single tile for the `ch.swisstopo.pixelkarte-farbe` layer:
4446

4547
```bash
4648
curl -o demo.jpg https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/9/266/180.jpeg
@@ -52,14 +54,14 @@ The output image:
5254

5355
### OpenLayers
5456

55-
An OpenLayers 3 example demonstrating the CadastralWebMap using the WMTS and the Tiled WMS:
57+
An OpenLayers 10 example showing the Base Map layer as XYZ tiles:
5658

57-
<iframe height="600" style="width: 100%;" scrolling="no" title="WMTS layer (EPSG:3857)" src="https://codepen.io/geoadmin/embed/pyzwwL?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
59+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/GgpXMyg?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
5860
</iframe>
5961

6062
<br/>
6163

62-
An OpenLayers example showing the SWISSIMAGE as XYZ:
64+
An OpenLayers 10 example showing the SWISSIMAGE layer as XYZ tiles:
6365

64-
<iframe height="600" style="width: 100%;" scrolling="no" title="xyz example" src="https://codepen.io/geoadmin/embed/xxYEwjQ?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
66+
<iframe height="600" style="width: 100%;" scrolling="no" src="https://codepen.io/geoadmin/embed/YPyOxoR?default-tab=js%2Cresult&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
6567
</iframe>

0 commit comments

Comments
 (0)