From 923b5ec3a051c49405c80ae30bab2e415df8596a Mon Sep 17 00:00:00 2001 From: John Arban Lewis Date: Mon, 4 Nov 2024 12:10:21 -0500 Subject: [PATCH 1/3] add marker for searched for location --- src/TempoLite.vue | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/TempoLite.vue b/src/TempoLite.vue index 151ce6b..5abd046 100644 --- a/src/TempoLite.vue +++ b/src/TempoLite.vue @@ -228,6 +228,7 @@ @set-location="(feature: MapBoxFeature) => { if (feature !== null) { map?.setView([feature.center[1], feature.center[0]], 12); + setMarker([feature.center[1], feature.center[0]]) } }" @error="(error: string) => searchErrorMessage = error" @@ -827,6 +828,9 @@ export default defineComponent({ }), cloudTimestamps, showClouds: false, + + showLocationMarker: true, + locationMarker: null as L.Marker | null, }; }, @@ -868,7 +872,7 @@ export default defineComponent({ maxZoom: 20, attribution: '© Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors', // crs: L.CRS.EPSG4326 - pane: 'labels' + // pane: 'labels' }).addTo(this.map as Map); @@ -1091,6 +1095,20 @@ export default defineComponent({ methods: { + setMarker(latlng: L.LatLngExpression) { + console.log(L.Icon.Default.prototype.options); + const icon = L.icon({ + ...L.Icon.Default.prototype.options, + iconRetinaUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png", + iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png", + shadowUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png", + }); + this.locationMarker = new L.Marker(latlng,{icon: icon}); + if (this.showLocationMarker) { + this.locationMarker.addTo(this.map as Map); + } + }, + cividis(x: number): string { return cividis(x); }, @@ -1360,6 +1378,18 @@ export default defineComponent({ } }, + showLocationMarker(show: boolean) { + if (this.locationMarker) { + if (show) { + this.locationMarker.addTo(this.map as Map); + return; + } else { + this.locationMarker.remove(); + return; + } + } + }, + timestamps() { this.singleDateSelected = this.uniqueDays[this.uniqueDays.length-1]; }, From 8b818347c578c7db32c0fc50ce9da9dd55079c8c Mon Sep 17 00:00:00 2001 From: John Arban Lewis Date: Mon, 4 Nov 2024 12:26:07 -0500 Subject: [PATCH 2/3] don't duplicate marker change it's location --- src/TempoLite.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TempoLite.vue b/src/TempoLite.vue index 5abd046..fb39a57 100644 --- a/src/TempoLite.vue +++ b/src/TempoLite.vue @@ -228,7 +228,7 @@ @set-location="(feature: MapBoxFeature) => { if (feature !== null) { map?.setView([feature.center[1], feature.center[0]], 12); - setMarker([feature.center[1], feature.center[0]]) + setMarker([feature.center[1], feature.center[0]]); } }" @error="(error: string) => searchErrorMessage = error" @@ -1103,7 +1103,11 @@ export default defineComponent({ iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png", shadowUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png", }); - this.locationMarker = new L.Marker(latlng,{icon: icon}); + if (this.locationMarker == null) { + this.locationMarker = new L.Marker(latlng,{icon: icon}); + } else { + this.locationMarker.setLatLng(latlng); + } if (this.showLocationMarker) { this.locationMarker.addTo(this.map as Map); } From 92b5bae9ff42c476746dd15445da0da81ddc4de1 Mon Sep 17 00:00:00 2001 From: John Arban Lewis Date: Mon, 4 Nov 2024 15:01:35 -0500 Subject: [PATCH 3/3] oops...put lines back on top --- src/TempoLite.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TempoLite.vue b/src/TempoLite.vue index fb39a57..dcd76e4 100644 --- a/src/TempoLite.vue +++ b/src/TempoLite.vue @@ -872,7 +872,7 @@ export default defineComponent({ maxZoom: 20, attribution: '© Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors', // crs: L.CRS.EPSG4326 - // pane: 'labels' + pane: 'labels' }).addTo(this.map as Map);