diff --git a/lizmap/modules/lizmap/controllers/features.classic.php b/lizmap/modules/lizmap/controllers/features.classic.php index be08dea34d..dcf8078bb2 100644 --- a/lizmap/modules/lizmap/controllers/features.classic.php +++ b/lizmap/modules/lizmap/controllers/features.classic.php @@ -105,11 +105,34 @@ public function tooltips() } } + // Prepare expressions to send to the Lizmap server plugin $tooltip = array( // Get tooltip in HTML 'tooltip' => $template, ); + // Get fields required for SLD rendering i.e. used in QGIS layer renderer + // For example for a categorized symbology based on a field + if (isset($tooltipLayers->{$layerName}->{'displayLayerStyle'}) + // TOTO FIX value if lizmap plugin saves a boolean + && $tooltipLayers->{$layerName}->{'displayLayerStyle'} == 'True' + ) { + $usedAttributes = qgisExpressionUtils::evaluateExpressions( + $qgisLayer, + array( + 'used_attributes' => "layer_renderer_used_attributes('".$layerId."')", + ) + ); + if ($usedAttributes + && property_exists($usedAttributes, 'used_attributes') + && is_array($usedAttributes->used_attributes) + ) { + foreach ($usedAttributes->used_attributes as $field) { + $tooltip[$field] = '[% "'.$field.'" %]'; + } + } + } + $data = qgisExpressionUtils::replaceExpressionText( $qgisLayer, $tooltip, diff --git a/tests/qgis-projects/tests/tooltip.qgs b/tests/qgis-projects/tests/tooltip.qgs index 8000b72305..65d2ab06d6 100644 --- a/tests/qgis-projects/tests/tooltip.qgs +++ b/tests/qgis-projects/tests/tooltip.qgs @@ -1,5 +1,5 @@ - + @@ -30,40 +30,40 @@ false - + - + - + - + - + - + - + @@ -76,12 +76,12 @@ quartiers_857e0547_f9cc_4a09_961f_0512df093a4c - + - - - - + + + + @@ -113,33 +113,33 @@ - - + + - + - + - - + + - + Annotations_4de31cb9_b92d_4388_985f_9285a60bd137 @@ -200,7 +200,7 @@ - + 3.80707036695971279 43.56670409545019851 @@ -267,7 +267,7 @@ - + @@ -292,275 +292,585 @@ 1 0 - + - + - + - + - + - + - + - + - + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - 0 0 1 - - - - + + + + - + - + - - + + - + @@ -632,11 +942,11 @@ - - - - - + + + + + @@ -647,16 +957,16 @@ - + - + - @@ -688,44 +998,32 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + "quartmno" <h1>Popup</h1><p>[% upper( "libquart" ) %]</p> - - - 3.80707036695971279 - 43.56670409545019851 - 3.94133068060567293 - 43.65337122449288643 - - - 3.80707036695971279 - 43.56670409545019851 - 3.94133068060567293 - 43.65337122449288643 - + quartiers_857e0547_f9cc_4a09_961f_0512df093a4c service='lizmapdb' key='quartier' estimatedmetadata=true srid=4326 type=MultiPolygon checkPrimaryKeyUnicity='1' table="tests_projects"."quartiers" (geom) quartiers-fields @@ -780,7 +1078,7 @@ def my_form_open(dialog, layer, feature): - + @@ -805,173 +1103,173 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -981,42 +1279,42 @@ def my_form_open(dialog, layer, feature): - + - + @@ -1025,38 +1323,38 @@ def my_form_open(dialog, layer, feature): - 0 0 1 - + @@ -1067,12 +1365,12 @@ def my_form_open(dialog, layer, feature): @@ -1135,11 +1433,11 @@ def my_form_open(dialog, layer, feature): - - - - - + + + + + @@ -1150,16 +1448,16 @@ def my_form_open(dialog, layer, feature): - + - + - @@ -1191,44 +1489,32 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + "quartmno" - - - 3.79986325786202084 - 43.55817897089504953 - 3.94908164824975216 - 43.68764871034932895 - - - 3.79986325786202084 - 43.55817897089504953 - 3.94908164824975216 - 43.68764871034932895 - + shop_bakery_pg_6070c1b0_fbbf_40a2_9e47_60f8145929fb service='lizmapdb' key='id' estimatedmetadata=true srid=4326 type=Point checkPrimaryKeyUnicity='1' table="tests_projects"."shop_bakery_pg" (geom) shop_bakery_pg @@ -1283,7 +1569,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1308,181 +1594,181 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -1492,9 +1778,9 @@ def my_form_open(dialog, layer, feature): @@ -1504,9 +1790,9 @@ def my_form_open(dialog, layer, feature): - @@ -1514,54 +1800,54 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -1569,16 +1855,16 @@ def my_form_open(dialog, layer, feature): - + - + @@ -1617,8 +1903,8 @@ def my_form_open(dialog, layer, feature): - - + + @@ -1626,13 +1912,13 @@ def my_form_open(dialog, layer, feature): - + - + - @@ -1664,35 +1950,23 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - + + - - + + - - + + "name" - - - 760748.21375807060394436 - 6280073.41499996930360794 - 771133.10960199660621583 - 6287018.72750705387443304 - - - 3.75235740324290035 - 43.61614002182462713 - 3.88192352806276819 - 43.67959702962149748 - + tramway_lines_030f06b5_be7a_4eba_bb33_9e5809bd82a1 service='lizmapdb' key='id_line' estimatedmetadata=true srid=2154 type=LineString checkPrimaryKeyUnicity='1' table="tests_projects"."tramway_lines" (geom) tramway_lines @@ -1747,7 +2021,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1772,189 +2046,189 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -1964,9 +2238,9 @@ def my_form_open(dialog, layer, feature): @@ -1976,9 +2250,9 @@ def my_form_open(dialog, layer, feature): - @@ -1986,54 +2260,54 @@ def my_form_open(dialog, layer, feature): 0 0 1 - - - - + + + + - + - + @@ -2041,16 +2315,16 @@ def my_form_open(dialog, layer, feature): - + - + @@ -2078,19 +2352,19 @@ def my_form_open(dialog, layer, feature): - + - + - + - @@ -2122,13 +2396,13 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - + - + - + @@ -2284,9 +2558,9 @@ def my_form_open(dialog, layer, feature): @@ -2309,7 +2583,7 @@ def my_form_open(dialog, layer, feature): - + nboisteault 2024-04-25T14:52:02 @@ -2319,9 +2593,9 @@ def my_form_open(dialog, layer, feature): - + - + PROJCRS["RGF93 v1 / Lambert-93",BASEGEOGCRS["RGF93 v1",DATUM["Reseau Geodesique Francais 1993 v1",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4171]],CONVERSION["Lambert-93",METHOD["Lambert Conic Conformal (2SP)",ID["EPSG",9802]],PARAMETER["Latitude of false origin",46.5,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8821]],PARAMETER["Longitude of false origin",3,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8822]],PARAMETER["Latitude of 1st standard parallel",49,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Latitude of 2nd standard parallel",44,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8824]],PARAMETER["Easting at false origin",700000,LENGTHUNIT["metre",1],ID["EPSG",8826]],PARAMETER["Northing at false origin",6600000,LENGTHUNIT["metre",1],ID["EPSG",8827]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Engineering survey, topographic mapping."],AREA["France - onshore and offshore, mainland and Corsica (France métropolitaine including Corsica)."],BBOX[41.15,-9.86,51.56,10.38]],ID["EPSG",2154]] +proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs @@ -2335,10 +2609,10 @@ def my_form_open(dialog, layer, feature): - + - + @@ -2348,27 +2622,27 @@ def my_form_open(dialog, layer, feature): @@ -2386,7 +2660,7 @@ def my_form_open(dialog, layer, feature): - + diff --git a/tests/qgis-projects/tests/tooltip.qgs.cfg b/tests/qgis-projects/tests/tooltip.qgs.cfg index c017409434..492f9eb8ad 100644 --- a/tests/qgis-projects/tests/tooltip.qgs.cfg +++ b/tests/qgis-projects/tests/tooltip.qgs.cfg @@ -253,7 +253,8 @@ "quartiers": { "layerId": "quartiers_6b25eb1d_e478_4059_929c_90e176e3aa34", "template": "

Tooltip

[% upper( \"libquart\" ) %]

Surface : [% round( $area /1000) %] km\u00b2

", - "displayGeom": "True", + "displayGeom": "False", + "displayLayerStyle": "True", "colorGeom": "#0000ff", "order": 0 },