Skip to content

Commit

Permalink
Adding support for a clickable map legend
Browse files Browse the repository at this point in the history
  • Loading branch information
computate committed Jan 11, 2024
1 parent 9ddb476 commit f461ae1
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/main/java/org/computate/frFR/java/EcrirePageClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -3200,24 +3200,17 @@ else if(entiteAttribuer) {
tl(0, "{{#block \"", langueConfig.getString(ConfigCles.var_jsLegende), "\"}}{{/block}}");
tl(3, "}");
l();
tl(3, "function ", langueConfig.getString(ConfigCles.var_htmLegende), classeNomSimple, "(map, shape, ", classeVarEmplacement, ", index, count) {");
tl(3, "function ", langueConfig.getString(ConfigCles.var_htmLegende), classeNomSimple, "(map, shape, ", StringUtils.uncapitalize(classeNomSimple), ", index, count) {");
tl(4, "var color = ", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacementCouleur, "[index];");
tl(4, "var title = ", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacementTitre, "[index];");
tl(4, "var url = ", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacementUrl, "[index];");
tl(4, "var htm = '';");
tl(4, "if(index == 0) {");
tl(5, "htm += `<div class=\"w3-white w3-padding w3-border w3-opacity w3-hover-opacity-off \">");
tl(1, "<div class=\"w3-larger font-weight-bold \">", classeNomAdjectifPluriel, "</div>");
tl(1, "<div>");
tl(4, "htm += `<div class=\"w3-white w3-padding w3-border w3-opacity w3-hover-opacity-off cursor-pointer \" style=\"max-width: 400px; \">");
tl(0, "`;");
tl(4, "}");
tl(4, "htm += `{{#block \"", langueConfig.getString(ConfigCles.var_htmLegende), "\"}}{{/block}}`;");
tl(4, "if(index == (count - 1)) {");
tl(5, "htm += `");
tl(1, "</div>");
tl(4, "htm += `");
tl(0, "</div>");
tl(0, "`;");
tl(4, "}");
tl(4, "return htm;");
tl(3, "}");
l();
Expand Down Expand Up @@ -3245,17 +3238,21 @@ else if(entiteAttribuer) {
tl(6, "else");
tl(7, "shapes.push(", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacement, ");");
tl(6, "shapes.forEach(function(shape, index) {");
tl(7, "htm += ", langueConfig.getString(ConfigCles.var_htmLegende), classeNomSimple, "(map, shape, ", classeVarEmplacement, ", index, shapes.length);");
tl(7, "htm += ", langueConfig.getString(ConfigCles.var_htmLegende), classeNomSimple, "(map, shape, ", StringUtils.uncapitalize(classeNomSimple), ", index, shapes.length);");
tl(6, "});");
tl(5, "}");
tl(4, "});");
tl(4, "div.innerHTML = htm;");
tl(4, "return div;");
tl(0, "{{/inline}}");
tl(0, "{{#*inline \"", langueConfig.getString(ConfigCles.var_htmLegende), classePageNomSimple, "\"}}");
tl(2, "<div>");
tl(2, "<div class=\"w3-row \" title=\"${quoteattr(title)}\">");
tl(2, "<div class=\"w3-col \" style=\"width: 20px; \">");
tl(3, "<i class=\"fa-light fa-circle\" style=\"color: ${color}; \"></i>");
tl(3, "<span data-", classeVarCleUnique, "=\"${", classeVarEmplacement, ".", classeVarCleUnique, "}\" onclick=\"window.geoJSONLayerGroup", classeNomSimple, ".getLayer(window.mapLayers[this.getAttribute('data-", classeVarCleUnique, "')]).openPopup(); return false;\" href=\"\">${title}</span>");
tl(2, "</div>");
tl(2, "<div class=\"w3-rest text-overflow-ellipsis \">");
tl(3, "<span class=\"\" data-", classeVarCleUnique, "=\"${", uncapitalizeClasseApiClasseNomSimple, ".", classeVarCleUnique, "}\" onclick=\"window.mapLayers[this.getAttribute('data-", classeVarCleUnique, "')].openPopup(); return false;\" href=\"\">${title}</span>");
tl(2, "</div>");
tl(2, "</div>");
tl(0, "{{/inline}}");
tl(0, "{{#*inline \"", langueConfig.getString(ConfigCles.var_jsStyle), classePageNomSimple, "\"}}");
Expand Down Expand Up @@ -4777,10 +4774,10 @@ else if(langueConfig.getString(ConfigCles.var_PUTCopie).equals(classeApiMethode)
auteurPageJs.tl(2, "function onEachFeature(feature, layer) {");
auteurPageJs.tl(3, "let popupContent = ", langueConfig.getString(ConfigCles.var_htmInfobulle), classeNomSimple, "(feature, layer);");
auteurPageJs.tl(3, "layer.bindPopup(popupContent);");
auteurPageJs.tl(3, "window.mapLayers[feature.properties.id] = layer._leaflet_id;");
auteurPageJs.tl(3, "window.mapLayers[feature.properties.id] = layer;");
auteurPageJs.tl(2, "};");
auteurPageJs.tl(2, "if(window.map", classeNomSimple, ") {");
auteurPageJs.tl(3, "window.geoJSONLayerGroup", classeNomSimple, ".clearLayers();");
auteurPageJs.tl(3, "window.geoJSON", classeNomSimple, ".clearLayers();");
auteurPageJs.tl(3, "$.each( window.", langueConfig.getString(ConfigCles.var_liste), classeNomSimple, ", function(index, ", StringUtils.uncapitalize(classeNomSimple), ") {");
auteurPageJs.tl(4, "if(", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacement, ") {");
auteurPageJs.tl(5, "var shapes = [];");
Expand All @@ -4802,20 +4799,20 @@ else if(langueConfig.getString(ConfigCles.var_PUTCopie).equals(classeApiMethode)
auteurPageJs.tl(8, "return L.circleMarker(latlng, ", langueConfig.getString(ConfigCles.var_jsStyle), classeNomSimple, "(feature));");
auteurPageJs.tl(7, "}");
auteurPageJs.tl(6, "});");
auteurPageJs.tl(6, "window.geoJSONLayerGroup", classeNomSimple, ".addLayer(layer);");
auteurPageJs.tl(6, "window.geoJSON", classeNomSimple, ".addLayer(layer);");
auteurPageJs.tl(5, "});");
auteurPageJs.tl(4, "}");
auteurPageJs.tl(3, "});");
auteurPageJs.tl(2, "} else {");
auteurPageJs.tl(3, "window.map", classeNomSimple, " = L.map('htmBody", langueConfig.getString(ConfigCles.var_Graphique), langueConfig.getString(ConfigCles.var_Emplacement), classePageNomSimple, "');");
auteurPageJs.tl(3, "window.map", classeNomSimple, " = L.map('htmBody", langueConfig.getString(ConfigCles.var_Graphique), langueConfig.getString(ConfigCles.var_Emplacement), classePageNomSimple, "', {closePopupOnClick: false});");
auteurPageJs.tl(3, "var data = [];");
auteurPageJs.tl(3, "var layout = {};");
auteurPageJs.tl(3, "layout['showlegend'] = true;");
auteurPageJs.tl(3, "layout['dragmode'] = 'zoom';");
auteurPageJs.tl(3, "layout['uirevision'] = 'true';");
auteurPageJs.tl(3, "var legend = L.control({position: 'bottomright'});");
auteurPageJs.tl(3, "legend.onAdd = ", langueConfig.getString(ConfigCles.var_jsLegende), classeNomSimple, ";");
auteurPageJs.tl(3, "//legend.addTo(window.map", classeNomSimple, ");");
auteurPageJs.tl(3, "legend.addTo(window.map", classeNomSimple, ");");
auteurPageJs.tl(3, "L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {");
auteurPageJs.tl(4, "maxZoom: 19,");
auteurPageJs.tl(4, "attribution: '&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'");
Expand All @@ -4829,7 +4826,8 @@ else if(langueConfig.getString(ConfigCles.var_PUTCopie).equals(classeApiMethode)
auteurPageJs.tl(4, "window.map", classeNomSimple, ".setView([window['DEFAULT_MAP_LOCATION']['lat'], window['DEFAULT_MAP_LOCATION']['lon']]);");
auteurPageJs.l();
auteurPageJs.tl(3, "layout['margin'] = { r: 0, t: 0, b: 0, l: 0 };");
auteurPageJs.tl(3, "window.geoJSONLayerGroup", classeNomSimple, " = L.geoJSON().addTo(window.map", classeNomSimple, ");");
auteurPageJs.tl(3, "window.geoJSON", classeNomSimple, " = L.geoJSON().addTo(window.map", classeNomSimple, ");");
//auteurPageJs.tl(3, "window.geoJSONLayerGroup", classeNomSimple, " = L.LayerGroup();");
auteurPageJs.tl(3, "$.each( window.", langueConfig.getString(ConfigCles.var_liste), classeNomSimple, ", function(index, ", StringUtils.uncapitalize(classeNomSimple), ") {");
auteurPageJs.tl(4, "if(", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacement, ") {");
auteurPageJs.tl(5, "var shapes = [];");
Expand All @@ -4851,7 +4849,7 @@ else if(langueConfig.getString(ConfigCles.var_PUTCopie).equals(classeApiMethode)
auteurPageJs.tl(8, "return L.circleMarker(latlng, ", langueConfig.getString(ConfigCles.var_jsStyle), classeNomSimple, "(feature));");
auteurPageJs.tl(7, "}");
auteurPageJs.tl(6, "});");
auteurPageJs.tl(6, "window.geoJSONLayerGroup", classeNomSimple, ".addLayer(layer);");
auteurPageJs.tl(6, "window.geoJSON", classeNomSimple, ".addLayer(layer);");
auteurPageJs.tl(5, "});");
auteurPageJs.tl(4, "}");
auteurPageJs.tl(3, "});");
Expand Down

0 comments on commit f461ae1

Please sign in to comment.