From 5004de8cf6e5c67e673470c0046eca99107ea848 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 9 Feb 2023 09:51:26 -0800 Subject: [PATCH] map: use terrain at high zoom levels --- lib/Controller/PageController.php | 1 + src/components/top-matter/MapSplitMatter.vue | 23 +++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 04520842..e4a5fe1f 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -117,6 +117,7 @@ class PageController extends Controller // Allow OSM $policy->addAllowedFrameDomain('www.openstreetmap.org'); $policy->addAllowedImageDomain('https://*.tile.openstreetmap.org'); + $policy->addAllowedImageDomain('https://*.a.ssl.fastly.net'); return $policy; } diff --git a/src/components/top-matter/MapSplitMatter.vue b/src/components/top-matter/MapSplitMatter.vue index 2fca1bb7..7b422cd3 100644 --- a/src/components/top-matter/MapSplitMatter.vue +++ b/src/components/top-matter/MapSplitMatter.vue @@ -8,7 +8,7 @@ @moveend="refresh" @zoomend="refresh" > - + Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.`; type IMarkerCluster = { id?: number; @@ -66,8 +68,6 @@ export default defineComponent({ }, data: () => ({ - url: TILE_URL, - attribution: ATTRIBUTION, zoom: 2, clusters: [] as IMarkerCluster[], }), @@ -82,6 +82,16 @@ export default defineComponent({ this.refresh(); }, + computed: { + tileurl() { + return this.zoom >= 5 ? OSM_TILE_URL : STAMEN_URL; + }, + + attribution() { + return this.zoom >= 5 ? OSM_ATTRIBUTION : STAMEN_ATTRIBUTION; + }, + }, + methods: { async refresh() { const map = this.$refs.map as LMap; @@ -96,7 +106,8 @@ export default defineComponent({ // Set query parameters to route if required const s = (x: number) => x.toFixed(6); const bounds = `${s(minLat)},${s(maxLat)},${s(minLon)},${s(maxLon)}`; - const zoom = map.mapObject.getZoom().toString(); + this.zoom = map.mapObject.getZoom(); + const zoom = this.zoom.toString(); if (this.$route.query.b === bounds && this.$route.query.z === zoom) { return; }