Skip to content

Commit 778dc9b

Browse files
committed
make circles with title or description show popup on click
1 parent f5bd595 commit 778dc9b

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

vue/src/components/SnapshotMap.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<!-- eslint-enable -->
1313

1414
<template>
15-
<v-content>
15+
<v-main>
1616
<v-slide-x-reverse-transition>
1717
<v-btn fab absolute small
1818
style="top:1.2em; right:1.3em;"
@@ -68,7 +68,7 @@
6868
<a href="https://www.openstreetmap.org/copyright" target="_blank">{{ $t('map') }}: Mapbox, © OpenStreetMap</a>
6969
</p>
7070

71-
</v-content>
71+
</v-main>
7272
</template>
7373

7474
<style>
@@ -209,6 +209,14 @@ export default {
209209
pointToLayer: (feature, latlng) => {
210210
if (feature.properties.radius) {
211211
// properties need to match https://leafletjs.com/reference-1.6.0.html#circle
212+
if (feature.properties.title || feature.properties.description) {
213+
feature.properties.className = 'popup-title-description';
214+
const clickcircle = new L.Circle(latlng, feature.properties);
215+
clickcircle.on('click', this.showTitleDescPopup);
216+
return clickcircle;
217+
}
218+
// if clickcircle has not been returned, return normal circle
219+
feature.properties.interactive = false;
212220
return new L.Circle(latlng, feature.properties);
213221
}
214222
return new L.Marker(latlng);
@@ -217,6 +225,17 @@ export default {
217225
return geoJsonExtended;
218226
},
219227
228+
showTitleDescPopup(e) {
229+
let content = e.target.options.description;
230+
if (e.target.options.title) {
231+
content = `<b>${e.target.options.title}</b><br />${content}`;
232+
}
233+
new L.Popup()
234+
.setLatLng(e.target._latlng) // eslint-disable-line no-underscore-dangle
235+
.setContent(content)
236+
.openOn(this.map);
237+
},
238+
220239
setupEmpty() {
221240
this.geobounds = this.geoboundsIn;
222241
},

vue/src/layouts/LayoutDefault.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<main>
33
<main-navigation />
44

5-
<v-content>
5+
<v-main>
66
<v-slide-y-transition mode="out-in">
77
<slot/>
88
</v-slide-y-transition>
9-
</v-content>
9+
</v-main>
1010
</main>
1111
</template>
1212

0 commit comments

Comments
 (0)