|
@@ -4,6 +4,7 @@
|
|
|
<no-ssr>
|
|
<no-ssr>
|
|
|
<l-map
|
|
<l-map
|
|
|
id="map"
|
|
id="map"
|
|
|
|
|
+ ref="vMap"
|
|
|
:zoom="zoom"
|
|
:zoom="zoom"
|
|
|
:center="center"
|
|
:center="center"
|
|
|
:bounds="bounds"
|
|
:bounds="bounds"
|
|
@@ -18,7 +19,8 @@
|
|
|
<l-marker
|
|
<l-marker
|
|
|
v-for="structure in structures"
|
|
v-for="structure in structures"
|
|
|
:key="structure.id"
|
|
:key="structure.id"
|
|
|
- :lat-lng="[structure.latitude, structure.longitude]">
|
|
|
|
|
|
|
+ :lat-lng="[structure.latitude, structure.longitude]"
|
|
|
|
|
+ >
|
|
|
<l-popup>
|
|
<l-popup>
|
|
|
<b>{{ structure.name }}</b><br>
|
|
<b>{{ structure.name }}</b><br>
|
|
|
{{ structure.postalCode }} {{ structure.addressCity }}<br>
|
|
{{ structure.postalCode }} {{ structure.addressCity }}<br>
|
|
@@ -70,19 +72,44 @@ export default {
|
|
|
bounds: defaultBounds,
|
|
bounds: defaultBounds,
|
|
|
isFirstRendering: true,
|
|
isFirstRendering: true,
|
|
|
shortcuts: [
|
|
shortcuts: [
|
|
|
- { src: '/images/metropole.png', alt: 'Metropole', bounds: { x1: 51.03, y1: -5.78, x2: 41.2, y2: 9.70 } },
|
|
|
|
|
- { src: '/images/guadeloupe.png', alt: 'Guadeloupe', bounds: { x1: 16.62, y1: -62.03, x2: 15.74, y2: -60.97 } },
|
|
|
|
|
- { src: '/images/martinique.png', alt: 'Martinique', bounds: { x1: 14.95, y1: -61.43, x2: 14.28, y2: -60.60 } },
|
|
|
|
|
- { src: '/images/mayotte.png', alt: 'Mayotte', bounds: { x1: -12.51, y1: 44.86, x2: -13.19, y2: 45.45 } },
|
|
|
|
|
- { src: '/images/la_reunion.png', alt: 'La Réunion', bounds: { x1: -20.65, y1: 54.92, x2: -21.65, y2: 56.15 } },
|
|
|
|
|
- { src: '/images/guyane.png', alt: 'Guyane', bounds: { x1: 6.24, y1: -54.62, x2: 1.87, y2: -50.59 } }
|
|
|
|
|
- ]
|
|
|
|
|
|
|
+ { src: '/images/metropole.png', alt: 'Metropole', bounds: [[51.03, -5.78], [41.2, 9.70]] },
|
|
|
|
|
+ { src: '/images/guadeloupe.png', alt: 'Guadeloupe', bounds: [[16.62, -62.03], [15.74, -60.97]] },
|
|
|
|
|
+ { src: '/images/martinique.png', alt: 'Martinique', bounds: [[14.95, -61.43], [14.28, -60.60]] },
|
|
|
|
|
+ { src: '/images/mayotte.png', alt: 'Mayotte', bounds: [[-12.51, 44.86], [-13.19, 45.45]] },
|
|
|
|
|
+ { src: '/images/la_reunion.png', alt: 'La Réunion', bounds: [[-20.65, 54.92], [-21.65, 56.15]] },
|
|
|
|
|
+ { src: '/images/guyane.png', alt: 'Guyane', bounds: [[6.24, -54.62], [1.87, -50.59]] }
|
|
|
|
|
+ ],
|
|
|
|
|
+ zoomRequired: false
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ structures () {
|
|
|
|
|
+ if (this.zoomRequired) {
|
|
|
|
|
+ this._fitBoundsToMarkers()
|
|
|
|
|
+ this.zoomRequired = false
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
setMapBounds (bounds) {
|
|
setMapBounds (bounds) {
|
|
|
- this.center = [0, 0] // << without this, the new bounds won't be properly set if you're already inside these new bounds.
|
|
|
|
|
- this.bounds = [[bounds.x1, bounds.y1], [bounds.x2, bounds.y2]]
|
|
|
|
|
|
|
+ this.bounds = bounds
|
|
|
|
|
+ this.$refs.vMap.mapObject.fitBounds(bounds) // << without this, the new bounds may not be properly set when the current view overlaps the new bounds.
|
|
|
|
|
+ },
|
|
|
|
|
+ resetBounds () {
|
|
|
|
|
+ this.setMapBounds(this.defaultBounds)
|
|
|
|
|
+ },
|
|
|
|
|
+ zoomOnResults () {
|
|
|
|
|
+ this.zoomRequired = true
|
|
|
|
|
+ },
|
|
|
|
|
+ _fitBoundsToMarkers () {
|
|
|
|
|
+ const coords = this.structures.filter(
|
|
|
|
|
+ (s) => { return s.latitude && s.longitude }
|
|
|
|
|
+ ).map(
|
|
|
|
|
+ (s) => { return [s.latitude, s.longitude] })
|
|
|
|
|
+ if (!coords.length > 0) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$refs.vMap.mapObject.fitBounds(coords)
|
|
|
},
|
|
},
|
|
|
boundsUpdated (newBounds) {
|
|
boundsUpdated (newBounds) {
|
|
|
// do not send and event on first automatic rendering
|
|
// do not send and event on first automatic rendering
|