maj de la syntaxe
This commit is contained in:
@@ -8,113 +8,113 @@
|
||||
export default {
|
||||
|
||||
onMounted() {
|
||||
var divCarte = this.$('div[ref="carte"]')
|
||||
var divCarte = this.$('div[ref="carte"]');
|
||||
|
||||
this.carte = L.map(divCarte).setView([46.8, 2.5], 6)
|
||||
this.groupeMarqueurs = L.layerGroup().addTo(this.carte)
|
||||
this.marqueursIndex = {}
|
||||
this.carte = L.map(divCarte).setView([46.8, 2.5], 6);
|
||||
this.groupeMarqueurs = L.layerGroup().addTo(this.carte);
|
||||
this.marqueursIndex = {};
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
}).addTo(this.carte)
|
||||
}).addTo(this.carte);
|
||||
|
||||
this.afficherMarqueurs()
|
||||
this.afficherMarqueurs();
|
||||
|
||||
var composant = this
|
||||
var composant = this;
|
||||
|
||||
setTimeout(function() {
|
||||
if (composant.carte) {
|
||||
composant.carte.invalidateSize()
|
||||
composant.carte.invalidateSize();
|
||||
}
|
||||
}, 200)
|
||||
}, 200);
|
||||
|
||||
setTimeout(function() {
|
||||
if (composant.carte) {
|
||||
composant.carte.invalidateSize()
|
||||
composant.carte.invalidateSize();
|
||||
}
|
||||
}, 500)
|
||||
}, 500);
|
||||
|
||||
window.mapFocus = function(id) {
|
||||
composant.centrerSurFormation(id)
|
||||
}
|
||||
composant.centrerSurFormation(id);
|
||||
};
|
||||
},
|
||||
|
||||
onUpdated() {
|
||||
this.afficherMarqueurs()
|
||||
this.afficherMarqueurs();
|
||||
|
||||
var composant = this
|
||||
var composant = this;
|
||||
|
||||
if (this.carte) {
|
||||
setTimeout(function() {
|
||||
composant.carte.invalidateSize()
|
||||
}, 100)
|
||||
composant.carte.invalidateSize();
|
||||
}, 100);
|
||||
|
||||
setTimeout(function() {
|
||||
composant.carte.invalidateSize()
|
||||
}, 300)
|
||||
composant.carte.invalidateSize();
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
onBeforeUnmount() {
|
||||
if (this.carte) {
|
||||
this.carte.remove()
|
||||
this.carte = null
|
||||
this.carte.remove();
|
||||
this.carte = null;
|
||||
}
|
||||
window.mapFocus = null
|
||||
window.mapFocus = null;
|
||||
},
|
||||
|
||||
afficherMarqueurs() {
|
||||
if (!this.carte || !this.groupeMarqueurs) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
this.groupeMarqueurs.clearLayers()
|
||||
this.marqueursIndex = {}
|
||||
this.groupeMarqueurs.clearLayers();
|
||||
this.marqueursIndex = {};
|
||||
|
||||
var coordonnees = []
|
||||
var formations = this.props.results || []
|
||||
var coordonnees = [];
|
||||
var formations = this.props.results || [];
|
||||
|
||||
for (var i = 0; i < formations.length; i++) {
|
||||
var f = formations[i]
|
||||
var f = formations[i];
|
||||
|
||||
if (f.latitude != null && f.longitude != null) {
|
||||
var marqueur = L.marker([f.latitude, f.longitude])
|
||||
marqueur.bindPopup('<b>' + f.nom + '</b><br>' + f.ville)
|
||||
marqueur.addTo(this.groupeMarqueurs)
|
||||
var marqueur = L.marker([f.latitude, f.longitude]);
|
||||
marqueur.bindPopup('<b>' + f.nom + '</b><br>' + f.ville);
|
||||
marqueur.addTo(this.groupeMarqueurs);
|
||||
|
||||
this.marqueursIndex[f.id] = marqueur
|
||||
coordonnees.push([f.latitude, f.longitude])
|
||||
this.marqueursIndex[f.id] = marqueur;
|
||||
coordonnees.push([f.latitude, f.longitude]);
|
||||
}
|
||||
}
|
||||
|
||||
if (coordonnees.length > 0) {
|
||||
this.carte.fitBounds(coordonnees, { padding: [20, 20] })
|
||||
this.carte.fitBounds(coordonnees, { padding: [20, 20] });
|
||||
} else {
|
||||
this.carte.setView([46.8, 2.5], 6)
|
||||
this.carte.setView([46.8, 2.5], 6);
|
||||
}
|
||||
},
|
||||
|
||||
centrerSurFormation(id) {
|
||||
var marqueur = this.marqueursIndex[id]
|
||||
var marqueur = this.marqueursIndex[id];
|
||||
|
||||
if (marqueur && this.carte) {
|
||||
var divCarte = this.$('div[ref="carte"]')
|
||||
var divCarte = this.$('div[ref="carte"]');
|
||||
|
||||
if (divCarte) {
|
||||
divCarte.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
divCarte.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
|
||||
var composant = this
|
||||
var composant = this;
|
||||
|
||||
setTimeout(function() {
|
||||
composant.carte.invalidateSize()
|
||||
composant.carte.setView(marqueur.getLatLng(), 13, { animate: true })
|
||||
marqueur.openPopup()
|
||||
}, 400)
|
||||
composant.carte.invalidateSize();
|
||||
composant.carte.setView(marqueur.getLatLng(), 13, { animate: true });
|
||||
marqueur.openPopup();
|
||||
}, 400);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
</map-view>
|
||||
|
||||
Reference in New Issue
Block a user