Skip to content

Commit e9fa16b

Browse files
Merge pull request #15 from geoadmin/feat-PB-1798-add-url-parameters-page
PB-1798 Add page "URL Parameters"
2 parents fe8b410 + db088cb commit e9fa16b

4 files changed

Lines changed: 136 additions & 0 deletions

File tree

.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ function downloadDataItems(): DefaultTheme.SidebarItem[] {
182182
function mapViewerItems(): DefaultTheme.SidebarItem[] {
183183
return [
184184
{ text: "iframe", link: "/docs/iframe" },
185+
{ text: "URL Parameters", link: "/docs/url-parameters" },
185186
{
186187
text: "JS API",
187188
link: "/docs/js-api",

docs/url-parameters.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# URL Parameters
2+
3+
Adjust the parameters in the URL of the map viewer to have full control over what is shown on the map.
4+
Use the URL to reproduce what you see right now on the map viewer anywhere.
5+
6+
## Introduction
7+
8+
The query string in the map viewer URL reflects what is currently displayed on the map.
9+
The query string is the part of the URL after the question mark and is composed of key-value pairs like in this example:
10+
11+
```txt
12+
https://map.geo.admin.ch/#/map?
13+
lang=en&
14+
center=2660000,1190000&
15+
z=1&
16+
topic=ech&
17+
layers=ch.swisstopo.swisstlm3d-wanderwege&
18+
bgLayer=ch.swisstopo.pixelkarte-farbe
19+
```
20+
21+
These key-value pairs are the "URL parameters" we present in the following.
22+
23+
:::tip
24+
The map viewer comes in two flavors:
25+
26+
- `https://map.geo.admin.ch/#/map`: The full-featured web map application that you see it on [map.geo.admin.ch](https://map.geo.admin.ch).
27+
28+
<iframe src="https://map.geo.admin.ch/#/map?lang=en&center=2600992.01,1197480.32&z=6&topic=ech&layers=&bgLayer=ch.swisstopo.pixelkarte-farbe" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
29+
30+
- `https://map.geo.admin.ch/#/embed`: A simplified version with less menus suitable for embedding the map viewer on your webpage.
31+
See [the tutorial about HTML iframes](/docs/iframe) for details.
32+
33+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2600992.01,1197480.32&z=6&topic=ech&layers=&bgLayer=ch.swisstopo.pixelkarte-farbe" style="border: 0;width: 400px;height: 300px;max-width: 100%;max-height: 100%;" allow="geolocation"></iframe>
34+
:::
35+
36+
## Parameter Overview
37+
38+
A list of all URL parameters available at [map.geo.admin.ch](https://map.geo.admin.ch).
39+
40+
| Parameter | Description | Values | Example |
41+
| ------------- | --------------------------- | ------------------- | -------- |
42+
| `lang` | Language of the application | de, fr, it, rm , en | https://map.geo.admin.ch/#/map?lang=rm |
43+
| `z` | Zoom level | 0, 1, ..., 13 | https://map.geo.admin.ch/#/map?z=12 |
44+
| `center` | Coordinates of center of the map view in LV95. The first value is the longitude-equivalent/easting, the second value is the latitude-equivalent/northing. The two are separated by a comma. | • Easting: between 2,450,000 and 2,900,000<br>• Northing: between 1,050,000 and 1,350,000 | https://map.geo.admin.ch/#/map?center=2700000,1140000 |
45+
| `topic` | Topic selected in the menu. Topics are groups of related datasets. | blw, are, bafu, swisstopo, kgs, funksender, nga, ivs, sachplan, geol, luftbilder, wildruhezonen, vu, inspire, ech | https://map.geo.admin.ch/#/map?topic=vu |
46+
| `bgLayer` | Background layer | ch.swisstopo.pixelkarte-farbe, ch.swisstopo.pixelkarte-grau, voidLayer | https://map.geo.admin.ch/#/map?bgLayer=ch.swisstopo.pixelkarte-grau |
47+
| `layers` | The layers in use. Each layer can be configured, see [layer parameters](#layer-parameters) for details. | See [layer parameters](#layer-parameters) | https://map.geo.admin.ch/#/map?layers=WMS|http://wms.geo.admin.ch/?|ch.swisstopo.geologie-geophysik-geothermie;ch.ensi.zonenplan-notfallschutz-kernanlagen |
48+
| `timeSlider` | Sets the year of the time slider. Format: `YYYY`, e.g. `1981`. Can be used with all "timeEnabled" levels. Special case WMS: An empty value (``timeSlider=`) means that the data for all years is displayed. | 0000, 0001, ...., 9999 | https://map.geo.admin.ch/#/map?layers=ch.swisstopo.lubis-luftbilder_farbe&timeSlider=1981 |
49+
| `crosshair` | Describes the type, easting and northing of a crosshair that is drawn on the map. | • Type: cross, circle, bowl, point, marker<br>• Easting/northing: see `center` | (1) https://map.geo.admin.ch/#/map?center=2538700,1165890&z=6&crosshair=circle<br>(2) https://map.geo.admin.ch/#/map?crosshair=cross,2600981,1197448 |
50+
| `swisssearch` | A query sent to the service behind the search bar. The map viewer shows the search result as if you would type it into the search bar manually. <br>ℹ️ To center map automatically on the first search result, use `&swisssearch_autoselect=true`, see also [the iframe documentation](/docs/iframe) | Any text | (1) https://map.geo.admin.ch/#/map?swisssearch=berges%2037%20payerne<br>(2) https://map.geo.admin.ch/#/map?swisssearch=7.04983,46.42928|
51+
| `compareRatio` | The relative position of the swipe elements visible in comparison mode | Floating point value between 0 and 1 | https://map.geo.admin.ch/#/map?compareRatio=0.5&bgLayer=ch.swisstopo.pixelkarte-farbe&layers=ch.swisstopo.geologie-generalkarte-ggk200 |
52+
| `featureInfo` | How to display the tooltip. More details in [the corresponding section](#tooltip). | default, bottomPanel, tooltip, none | https://map.geo.admin.ch/#/map?layers=ch.bav.haltestellen-oev@features=8500010&lang=fr&featureInfo=bottomPanel |
53+
| `geolocation` | Whether to enable geolocation. | true, false | https://map.geo.admin.ch/#/map?lang=fr&geolocation=true |
54+
| `noSimpleZoom` | Whether to require that the CTRL/CMD button is pressed. This only takes effect in the [`embed` mode](#introduction). | true, false | https://map.geo.admin.ch/#/embed?&noSimpleZoom=true |
55+
56+
## Layer Parameters
57+
58+
Layer parameters in query parameter `layers` describe which layers are chosen and how those layers are configured.
59+
60+
For example, a layer configuration in the map viewer that looks like this
61+
62+
![Layer configuration](../static/url-parameters-layers-gui.png){width=400px height=200px}
63+
64+
is represented by a `layers` query parameter like this:
65+
66+
```txt
67+
layers=ch.swisstopo.zeitreihen@year=2018,t,0.6
68+
╰──────────┬──────────╯╰───┬────╯╰┬╯╰┬╯
69+
identifier timestamp │ ╰ opacity
70+
visibility
71+
```
72+
73+
where
74+
75+
- `identifier`: The "technical name" of the layer, for example `ch.swisstopo.zeitreihen`. You can find this identifier either in the URL when choosing the layer in the map viewer or through [geocat](https://www.geocat.ch). A full list of available layers can be listed by [the `/collections` endpoint of the STAC API](https://data.geo.admin.ch/api/stac/static/spec/v1/api.html#tag/Data/operation/getCollections).
76+
- `timestamp`: Designates the version in time of the layer. Currently you can only select a version by year using the `@year=` prefix.
77+
- `visibility`: `t` (or empty) for "true" if the layer is displayed on the map, `f` for "false" if the layer is listed in the menu but not displayed on the map
78+
- `opacity`: The transparency of the layer. The value ranges from 0.0 (transparent) to 1.0 (opaque).
79+
80+
The layer parameters are separated by comma (`,`). You can have multiple layers by separating them with a semicolon (`;`).
81+
82+
As an illustration:
83+
84+
![Layer parameters](../static/url-parameters-layer-parameters.png)
85+
86+
## Feature Selection
87+
88+
Center the map on a selected feature by using a special [layer parameter](#layer-parameters): `@features`.
89+
90+
For example, a map like this:
91+
92+
<iframe src="https://map.geo.admin.ch/#/embed?layers=ch.astra.unfaelle-personenschaeden_fahrraeder@features=769AE49DEC6D0106E0530A839427D480" style="border: 0;width: 688px;height: 300px;max-width: 100%;max-height: 100%;margin-top: 50px;" allow="geolocation"></iframe>
93+
94+
is represented by a URL like
95+
96+
https://map.geo.admin.ch/#/embed?layers=ch.astra.unfaelle-personenschaeden_fahrraeder@features=769AE49DEC6D0106E0530A839427D480
97+
98+
Multiple features are separated by a colon (`:`) like in this example
99+
100+
<iframe src="https://map.geo.admin.ch/#/embed?layers=ch.astra.unfaelle-personenschaeden_fahrraeder@features=203F7E8B2D110152E0630AB38B028D9D:769AE49DEC6D0106E0530A839427D480:98CDD8F6D5493E0BE05329B9D80AAB05" style="border: 0;width: 688px;height: 300px;max-width: 100%;max-height: 100%;margin-top: 50px;" allow="geolocation"></iframe>
101+
102+
with URL
103+
104+
https://map.geo.admin.ch/#/embed?layers=ch.astra.unfaelle-personenschaeden_fahrraeder@features=203F7E8B2D110152E0630AB38B028D9D:769AE49DEC6D0106E0530A839427D480:98CDD8F6D5493E0BE05329B9D80AAB05
105+
106+
## Tooltip
107+
108+
The query parameter `featureInfo` lets you choose from different options how to display a tooltip.
109+
A tooltip is a text box with metadata that pops up when you select a feature in the map viewer.
110+
111+
The available options are:
112+
113+
- `default`: Places the tooltip in the default location most suitable for your device.
114+
For mobile devices, the default corresponds to option `bottomPanel`, for desktop the default is the floating `tooltip`.
115+
116+
https://map.geo.admin.ch/#/embed?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=default
117+
118+
119+
- `bottomPanel`: Places the tooltip at the bottom of the map. This is the default location for mobile devices.
120+
121+
https://map.geo.admin.ch/#/map?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=bottomPanel
122+
123+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=bottomPanel" style="border: 0;width: 688px;height: 300px;max-width: 100%;max-height: 100%;margin-top: 50px;" allow="geolocation"></iframe>
124+
125+
- `tooltip`: Places the tooltip over the map, as a floating element. This is the default behaviour on the desktop.
126+
127+
https://map.geo.admin.ch/#/map?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=tooltip
128+
129+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=tooltip" style="border: 0;width: 688px;height: 300px;max-width: 100%;max-height: 100%;margin-top: 50px;" allow="geolocation"></iframe>
130+
131+
- `none`: The tooltip is hidden.
132+
133+
https://map.geo.admin.ch/#/map?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=none
134+
135+
<iframe src="https://map.geo.admin.ch/#/embed?lang=en&center=2611363,1266310&z=9&bgLayer=ch.swisstopo.pixelkarte-farbe&topic=ech&layers=ch.bav.haltestellen-oev@features=8500010&featureInfo=none" style="border: 0;width: 688px;height: 300px;max-width: 100%;max-height: 100%;margin-top: 50px;" allow="geolocation"></iframe>
209 KB
Loading
100 KB
Loading

0 commit comments

Comments
 (0)