Skip to content

Commit 5c07d09

Browse files
authored
Show zoom level in map corner on the layers documentation (#96)
* On basemaps layers docs, show the current zoom level. * use language-script pairs from library. * update favicon. * update opengraph
1 parent 288e18a commit 5c07d09

File tree

4 files changed

+46
-178
lines changed

4 files changed

+46
-178
lines changed

.vitepress/config.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { defineConfig } from "vitepress";
33
// https://vitepress.dev/reference/site-config
44
export default defineConfig({
55
title: "Protomaps Docs",
6-
head: [["link", { rel: "icon", type: "image/png", href: "/favicon.png" }]],
6+
head: [
7+
["link", { rel: "icon", type: "image/png", href: "/favicon.png" }],
8+
["meta", { property: "og:image", content: "https://protomaps.com/docs_opengraph.jpg" }]
9+
],
710
description: "Technical Documentation for Protomaps",
811
cleanUrls: true,
912
markdown: {

basemaps/layers.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The current version is **Version 4**.
4747

4848
## boundaries
4949

50-
<MaplibreMap highlightLayer="boundaries" :zoom=5 :lat="52" :lng="4"/>
50+
<MaplibreMap highlightLayer="boundaries" :zoom=5 :showZoom="true" :lat="52" :lng="4"/>
5151

5252
| Key | Values | Description |
5353
| ------------- | ----------------------------------------- | --------------------------------- |
@@ -58,7 +58,7 @@ The current version is **Version 4**.
5858

5959
## buildings
6060

61-
<MaplibreMap highlightLayer="buildings" :zoom=14 :lat="51.5" :lng="-0.2"/>
61+
<MaplibreMap highlightLayer="buildings" :zoom=14 :showZoom="true" :lat="51.5" :lng="-0.2"/>
6262

6363
Buildings from OpenStreetMap. z0-14 contains merged buildings, even disconnected ones. z15+ contains individual OSM equivalent buildings.
6464

@@ -71,7 +71,7 @@ Buildings from OpenStreetMap. z0-14 contains merged buildings, even disconnected
7171

7272
## earth
7373

74-
<MaplibreMap highlightLayer="earth" :zoom=3 :lat="-4.5" :lng="127"/>
74+
<MaplibreMap highlightLayer="earth" :zoom=3 :showZoom="true" :lat="-4.5" :lng="127"/>
7575

7676
Polygons from the Natural Earth 50m `land` theme for z0-z4, 10m for z5, preprocessed land polygons from [OSMCoastline](https://osmdata.openstreetmap.de) for z6+.
7777

@@ -81,7 +81,7 @@ Polygons from the Natural Earth 50m `land` theme for z0-z4, 10m for z5, preproce
8181

8282
## landcover
8383

84-
<MaplibreMap highlightLayer="landcover" :zoom=2 :lat="38" :lng="-100"/>
84+
<MaplibreMap highlightLayer="landcover" :zoom=2 :showZoom="true" :lat="38" :lng="-100"/>
8585

8686
Polygons from the Daylight distribution's [landcover](https://daylightmap.org/2023/10/11/landcover.html) theme, for z0-z7.
8787

@@ -93,7 +93,7 @@ _NOTE: It's recommended to pair with **natural** layer polygons in from OpenStre
9393

9494
## landuse
9595

96-
<MaplibreMap highlightLayer="landuse" :zoom=13 :lat="-1.28" :lng="36.8"/>
96+
<MaplibreMap highlightLayer="landuse" :zoom=13 :showZoom="true" :lat="-1.28" :lng="36.8"/>
9797

9898
Polygons from OpenStreetMap, from a curated subset of `aeroway`, `amenity`, `area:aeroway`, `boundary`, `highway`, `landuse`, `leisure`, `man_made`, `natural`, `place`, `railway`, `tourism` tags, for all zooms.
9999

@@ -166,7 +166,7 @@ Polygons from OpenStreetMap, from a curated subset of `aeroway`, `amenity`, `are
166166

167167
Points from OpenStreetMap and Natural Earth, from a curated subset of place tags, for all zooms.
168168

169-
<MaplibreMap highlightLayer="places" :zoom=2 :lat="-24.6" :lng="134"/>
169+
<MaplibreMap highlightLayer="places" :zoom=2 :showZoom="true" :lat="-24.6" :lng="134"/>
170170

171171
| Key | Values | Description |
172172
| ----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ----------: |
@@ -181,7 +181,7 @@ Points from OpenStreetMap and Natural Earth, from a curated subset of place tags
181181

182182
Points from OpenStreetMap, from a curated subset of aeroway, amenity, attraction, boundary, craft, highway, historic, landuse, leisure, natural, railway, shop, tourism tags, for all zooms.
183183

184-
<MaplibreMap highlightLayer="pois" :zoom=16 :lat="52.525" :lng="13.41"/>
184+
<MaplibreMap highlightLayer="pois" :zoom=16 :showZoom="true" :lat="52.525" :lng="13.41"/>
185185

186186
| Key | Values | Description |
187187
| ---------- | :-------: | ----------: |
@@ -345,7 +345,7 @@ _NOTE: The list of kind values is not comprehensive as some raw OSM tag values a
345345
Linear transportation features designed for movement, including highways, streets,
346346
railways and piers from OpenStreetMap. This layer represents built infrastructure including railways. Refer to the [transit](#transit) layer for passenger services.
347347

348-
<MaplibreMap highlightLayer="roads" :zoom=13 :lat="35.68" :lng="139.76"/>
348+
<MaplibreMap highlightLayer="roads" :zoom=13 :showZoom="true" :lat="35.68" :lng="139.76"/>
349349

350350
| Key | Values | Description |
351351
| -------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ----------: |
@@ -391,7 +391,7 @@ This layer is currently empty.
391391

392392
## water
393393

394-
<MaplibreMap highlightLayer="water" :zoom=6 :lat="-1.3" :lng="-49"/>
394+
<MaplibreMap highlightLayer="water" :zoom=6 :showZoom="true" :lat="-1.3" :lng="-49"/>
395395

396396
Polygons from the Natural Earth 50m `lakes` and `ocean` themes for z0-z4, 10m for z5, preprocessed land polygons from [OSMCoastline](https://osmdata.openstreetmap.de) for z6+.
397397

components/MaplibreMap.vue

Lines changed: 33 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import maplibregl from "maplibre-gl";
33
import { ref, onMounted, onUpdated, watch } from "vue";
44
import { default as layers } from "protomaps-themes-base";
5+
import { language_script_pairs } from "protomaps-themes-base";
56
import { useData } from "vitepress";
67
78
const { isDark } = useData();
@@ -10,6 +11,7 @@ const mapRef = ref(null);
1011
var map;
1112
1213
const lang = ref("en");
14+
const currentZoom = ref(0);
1315
1416
const tableFromProps = (props: unknown) => {
1517
let tableHTML = "<table>";
@@ -103,6 +105,7 @@ const props = defineProps<{
103105
lat?: number;
104106
lng?: number;
105107
langSelect?: boolean;
108+
showZoom?: boolean;
106109
}>();
107110
108111
onMounted(() => {
@@ -112,6 +115,7 @@ onMounted(() => {
112115
false,
113116
);
114117
}
118+
currentZoom.value = props.zoom;
115119
map = new maplibregl.Map({
116120
container: mapRef.value,
117121
style: style(props.theme, props.highlightLayer),
@@ -146,178 +150,17 @@ onMounted(() => {
146150
popup.remove();
147151
},
148152
);
153+
154+
map.on("zoom", () => {
155+
currentZoom.value = map.getZoom().toFixed(2);
156+
});
149157
});
150158
151159
watch([isDark, lang], () => {
152160
map.setStyle(style(props.theme, props.highlightLayer, lang.value));
153161
});
154162
155-
const language_script_pairs = [
156-
{
157-
lang: "ar",
158-
full_name: "Arabic",
159-
},
160-
{
161-
lang: "cs",
162-
full_name: "Czech",
163-
},
164-
{
165-
lang: "bg",
166-
full_name: "Bulgarian",
167-
},
168-
{
169-
lang: "da",
170-
full_name: "Danish",
171-
},
172-
{
173-
lang: "de",
174-
full_name: "German",
175-
},
176-
{
177-
lang: "el",
178-
full_name: "Greek",
179-
},
180-
{
181-
lang: "en",
182-
full_name: "English",
183-
},
184-
{
185-
lang: "es",
186-
full_name: "Spanish",
187-
},
188-
{
189-
lang: "et",
190-
full_name: "Estonian",
191-
},
192-
{
193-
lang: "fa",
194-
full_name: "Persian",
195-
},
196-
{
197-
lang: "fi",
198-
full_name: "Finnish",
199-
},
200-
{
201-
lang: "fr",
202-
full_name: "French",
203-
},
204-
{
205-
lang: "ga",
206-
full_name: "Irish",
207-
},
208-
{
209-
lang: "he",
210-
full_name: "Hebrew",
211-
},
212-
{
213-
lang: "hi",
214-
full_name: "Hindi",
215-
},
216-
{
217-
lang: "hr",
218-
full_name: "Croatian",
219-
},
220-
{
221-
lang: "hu",
222-
full_name: "Hungarian",
223-
},
224-
{
225-
lang: "id",
226-
full_name: "Indonesian",
227-
},
228-
{
229-
lang: "it",
230-
full_name: "Italian",
231-
},
232-
{
233-
lang: "ja",
234-
full_name: "Japanese",
235-
},
236-
{
237-
lang: "ko",
238-
full_name: "Korean",
239-
},
240-
{
241-
lang: "lt",
242-
full_name: "Lithuanian",
243-
},
244-
{
245-
lang: "lv",
246-
full_name: "Latvian",
247-
},
248-
{
249-
lang: "ne",
250-
full_name: "Nepali",
251-
},
252-
{
253-
lang: "nl",
254-
full_name: "Dutch",
255-
},
256-
{
257-
lang: "no",
258-
full_name: "Norwegian",
259-
},
260-
{
261-
lang: "mr",
262-
full_name: "Marathi",
263-
},
264-
{
265-
lang: "mt",
266-
full_name: "Maltese",
267-
},
268-
{
269-
lang: "pl",
270-
full_name: "Polish",
271-
},
272-
{
273-
lang: "pt",
274-
full_name: "Portuguese",
275-
},
276-
{
277-
lang: "ro",
278-
full_name: "Romanian",
279-
},
280-
{
281-
lang: "ru",
282-
full_name: "Russian",
283-
},
284-
{
285-
lang: "sk",
286-
full_name: "Slovak",
287-
},
288-
{
289-
lang: "sl",
290-
full_name: "Slovenian",
291-
},
292-
{
293-
lang: "sv",
294-
full_name: "Swedish",
295-
},
296-
{
297-
lang: "tr",
298-
full_name: "Turkish",
299-
},
300-
{
301-
lang: "uk",
302-
full_name: "Ukrainian",
303-
},
304-
{
305-
lang: "ur",
306-
full_name: "Urdu",
307-
},
308-
{
309-
lang: "vi",
310-
full_name: "Vietnamese",
311-
},
312-
{
313-
lang: "zh-Hans",
314-
full_name: "Chinese (Simplified)",
315-
},
316-
{
317-
lang: "zh-Hant",
318-
full_name: "Chinese (Traditional)",
319-
},
320-
].sort((a, b) => a.full_name.localeCompare(b.full_name));
163+
language_script_pairs.sort((a, b) => a.full_name.localeCompare(b.full_name));
321164
</script>
322165

323166
<template>
@@ -330,19 +173,34 @@ const language_script_pairs = [
330173
{{ option.full_name }}
331174
</option>
332175
</select>
333-
<div ref="mapRef" class="maplibre-map"></div>
176+
<div class="map-container">
177+
<div ref="mapRef" class="maplibre-map"></div>
178+
<div v-if="props.showZoom" class="zoom-display">z={{ currentZoom }}</div>
179+
</div>
334180
</template>
335181

336182
<style>
337183
@import "maplibre-gl/dist/maplibre-gl.css";
338184
</style>
339185

340186
<style>
187+
.map-container {
188+
position: relative;
189+
}
190+
341191
.maplibre-map {
342192
height: 300px;
343193
width: 100%;
344194
}
345195
196+
.zoom-display {
197+
position: absolute;
198+
bottom: 0;
199+
font-size: 12px;
200+
padding-left: 0.3rem;
201+
padding-right: 0.3rem;
202+
}
203+
346204
.docs-popup .maplibregl-popup-content {
347205
padding: 4px;
348206
}
@@ -356,10 +214,17 @@ const language_script_pairs = [
356214
border-bottom-color: rgb(22, 22, 24);
357215
}
358216
359-
.dark .maplibregl-ctrl-attrib {
217+
.dark .maplibregl-ctrl-attrib,
218+
.dark .zoom-display {
360219
background-color: hsla(0, 0%, 0%, 0.5);
361220
}
362221
.dark .maplibregl-ctrl-attrib a {
363222
color: rgba(235, 235, 245, 0.6);
364223
}
224+
225+
select {
226+
background: var(--vp-sidebar-bg-color);
227+
padding-left: 0.5rem;
228+
margin-bottom: 0.5rem;
229+
}
365230
</style>

public/favicon.png

685 Bytes
Loading

0 commit comments

Comments
 (0)