From 4d515a8b000583b01d3a82bebee39addfcc73f13 Mon Sep 17 00:00:00 2001 From: martins Date: Fri, 31 Mar 2023 16:31:25 +0200 Subject: [PATCH] petit ajout marker on click --- riot/maMap.riot | 19 +++++++------------ riot/tableuFormation.riot | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/riot/maMap.riot b/riot/maMap.riot index 0905410..c96a409 100644 --- a/riot/maMap.riot +++ b/riot/maMap.riot @@ -23,7 +23,7 @@ onUpdated() { if (this.props.records) { this.removeMarks(); - this.afficheMarks(this.getLoc(this.props.records)); + this.afficheMarks(this.props.records); this.onMoveEnd(); } }, @@ -34,9 +34,12 @@ }); }, - afficheMarks(loc) { - loc.forEach((coord) => { - var marker = L.marker([coord[0], coord[1]]).addTo(map); + afficheMarks(records) { + records.forEach((item) => { + var marker = L.marker([item.fields.g_olocalisation_des_formations[0], item.fields.g_olocalisation_des_formations[1]]).addTo(map); + marker.on('click', () => { + this.props.afficherModal(item) + }); markers.push(marker); }); }, @@ -54,14 +57,6 @@ }, - getLoc(records) { - let loc = []; - records.forEach((formation) => { - loc.push(formation.fields.g_olocalisation_des_formations); - }); - return loc; - }, - // méthode pour gérer l'événement "moveend" onMoveEnd() { let visibleMarkers = this.getVisibleMarkers(); diff --git a/riot/tableuFormation.riot b/riot/tableuFormation.riot index f6e82da..19f1cdc 100644 --- a/riot/tableuFormation.riot +++ b/riot/tableuFormation.riot @@ -1,6 +1,6 @@
- +