@@ -130,17 +130,17 @@ function generateMap(zoomHomeButton) {
130
130
fullScreenButton . attr ( "data-toggle" , "tooltip" ) ;
131
131
fullScreenButton . attr ( "data-original-title" , "Fullscreen" ) ;
132
132
$ ( ".leaflet-control-fullscreen-button" ) . removeAttr ( "title" ) ;
133
-
133
+
134
134
// Add scale depending on the configuration
135
135
if ( configuration . MAP . ENABLE_SCALE ) {
136
136
L . control . scale (
137
137
{
138
- imperial : false ,
138
+ imperial : false ,
139
139
position : 'bottomright'
140
140
}
141
141
) . addTo ( map ) ;
142
142
}
143
-
143
+
144
144
return map ;
145
145
}
146
146
@@ -425,7 +425,10 @@ function onEachFeaturePointLastObs(feature, layer) {
425
425
popupContent +
426
426
"</br> <a href='" +
427
427
configuration . URL_APPLICATION +
428
-
428
+ < << << << HEAD
429
+
430
+ === = ===
431
+ >>> > >>> 8 da0f00 ( fix : show right taxons names for municipality default meshes map view )
429
432
language +
430
433
"/espece/" +
431
434
feature . properties . cd_ref +
@@ -537,31 +540,28 @@ function compare(a, b) {
537
540
return 0 ;
538
541
}
539
542
540
- function printEspece ( tabEspece , tabCdRef ) {
541
- stringEspece = "" ;
542
- i = 0 ;
543
- while ( i < tabEspece . length ) {
544
- stringEspece +=
545
- "<li> <a href='" +
546
- configuration . URL_APPLICATION +
547
- "/espece/" +
548
- tabCdRef [ i ] +
549
- "'>" +
550
- tabEspece [ i ] +
551
- "</li>" ;
552
-
553
- i = i + 1 ;
554
- }
555
- return stringEspece ;
543
+ function buildSpeciesEntries ( taxons ) {
544
+ rows = [ ] ;
545
+ taxons . forEach ( taxon => {
546
+ href = `${ configuration . URL_APPLICATION } /espece/${ taxon . cdRef } `
547
+ rows . push ( `<li><a href="${ href } ">${ taxon . name } </li>` ) ;
548
+ } ) ;
549
+ return rows . join ( '\n' ) ;
556
550
}
557
551
558
552
function onEachFeatureMailleLastObs ( feature , layer ) {
553
+ < << << << HEAD
559
554
popupContent =
560
555
"<b>Espèces observées dans la maille: </b> <ul> " +
561
556
printEspece ( feature . properties . list_taxon , feature . properties . list_cdref ) +
562
557
"</ul>" ;
558
+ = === ===
559
+ title = `${ feature . properties . taxons . length } espèces observées dans la maille : ` ;
560
+ rows = buildSpeciesEntries ( feature . properties . taxons ) ;
561
+ popupContent = `<b>${ title } </b><ul>${ rows } </ul>` ;
562
+ > >>> >>> 8 da0f00 ( fix : show right taxons names for municipality default meshes map view )
563
563
564
- layer . bindPopup ( popupContent ) ;
564
+ layer . bindPopup ( popupContent , { maxHeight : 300 } ) ;
565
565
}
566
566
567
567
function styleMailleLastObs ( ) {
@@ -574,34 +574,41 @@ function styleMailleLastObs() {
574
574
}
575
575
576
576
function generateGeoJsonMailleLastObs ( observations ) {
577
- var i = 0 ;
578
- myGeoJson = { type : "FeatureCollection" , features : [ ] } ;
579
- while ( i < observations . length ) {
580
- geometry = observations [ i ] . geojson_maille ;
581
- idMaille = observations [ i ] . id_maille ;
582
- properties = {
583
- id_maille : idMaille ,
584
- list_taxon : [ observations [ i ] . taxon ] ,
585
- list_cdref : [ observations [ i ] . cd_ref ] ,
586
- list_id_observation : [ observations [ i ] . id_observation ] ,
587
- } ;
588
- var j = i + 1 ;
589
- while ( j < observations . length && observations [ j ] . id_maille == idMaille ) {
590
- properties . list_taxon . push ( observations [ j ] . taxon ) ;
591
- properties . list_cdref . push ( observations [ j ] . cd_ref ) ;
592
- properties . list_id_observation . push ( observations [ j ] . id_observation ) ;
593
- j = j + 1 ;
577
+ var features = [ ] ;
578
+ observations . forEach ( ( obs ) => {
579
+ findedFeature = features . find (
580
+ ( feat ) => feat . properties . meshId === obs . id_maille
581
+ ) ;
582
+ if ( ! findedFeature ) {
583
+ features . push ( {
584
+ type : "Feature" ,
585
+ geometry : obs . geojson_maille ,
586
+ properties : {
587
+ meshId : obs . id_maille ,
588
+ taxons : [
589
+ {
590
+ cdRef : obs . cd_ref ,
591
+ name : obs . taxon ,
592
+ } ,
593
+ ] ,
594
+ } ,
595
+ } ) ;
596
+ } else if (
597
+ ! findedFeature . properties . taxons . find (
598
+ ( taxon ) => taxon . cdRef === obs . cd_ref
599
+ )
600
+ ) {
601
+ findedFeature . properties . taxons . push ( {
602
+ cdRef : obs . cd_ref ,
603
+ name : obs . taxon ,
604
+ } ) ;
594
605
}
595
- myGeoJson . features . push ( {
596
- type : "Feature" ,
597
- properties : properties ,
598
- geometry : geometry ,
599
- } ) ;
600
- // on avance jusqu' à j
601
- i = j ;
602
- }
606
+ } ) ;
603
607
604
- return myGeoJson ;
608
+ return {
609
+ type : "FeatureCollection" ,
610
+ features : features ,
611
+ } ;
605
612
}
606
613
607
614
function find_id_observation_in_array ( tab_id , id_observation ) {
0 commit comments