diff --git a/assets/src/modules/Popup.js b/assets/src/modules/Popup.js index 44f474b6f2..4307f2b365 100644 --- a/assets/src/modules/Popup.js +++ b/assets/src/modules/Popup.js @@ -107,7 +107,8 @@ export default class Popup { const xCoord = evt?.xy?.x || evt?.pixel?.[0]; const yCoord = evt?.xy?.y || evt?.pixel?.[1]; - let candidateLayers = this._lizmapState.rootMapGroup.findMapLayers().reverse(); + // Order popups following layers order + let candidateLayers = this._lizmapState.rootMapGroup.findMapLayers().toSorted((a, b) => b.layerOrder - a.layerOrder); // Only request visible layers candidateLayers = candidateLayers.filter(layer => layer.visibility); diff --git a/tests/end2end/playwright/layer_order.spec.js b/tests/end2end/playwright/layer_order.spec.js new file mode 100644 index 0000000000..71197c945b --- /dev/null +++ b/tests/end2end/playwright/layer_order.spec.js @@ -0,0 +1,33 @@ +// @ts-check +import { test, expect } from '@playwright/test'; +import { gotoMap } from './globals'; + +test.describe('Layer order', () => { + + test('Layer order in map and popups', async ({ page }) => { + const url = '/index.php/view/map/?repository=testsrepository&project=layer_order'; + await gotoMap(url, page); + + // Assert layers order is as defined in QGIS + expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('quartiers').getZIndex())).toEqual(0); + expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('sousquartiers').getZIndex())).toEqual(1); + expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('tramway_lines').getZIndex())).toEqual(2); + expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('tramway_stops').getZIndex())).toEqual(3); + + // Assert popups order is as defined in QGIS + await page.locator('#newOlMap').click({ + position: { + x: 428, + y: 260 + } + }); + + let popups = page.locator(".lizmapPopupSingleFeature"); + await expect(popups).toHaveCount(4); + + await expect(popups.nth(0)).toHaveAttribute("data-layer-id", "tramway_stops_437c64d6_adbb_4018_95d6_1f8f8cd6a81c"); + await expect(popups.nth(1)).toHaveAttribute("data-layer-id", "tramway_lines_684f9541_dd3a_4f2d_9233_89f379413a18"); + await expect(popups.nth(2)).toHaveAttribute("data-layer-id", "sousquartiers_274734f2_9aee_4acd_abaf_ba5692d1fd20"); + await expect(popups.nth(3)).toHaveAttribute("data-layer-id", "quartiers_9226ee56_fa1c_44f8_8447_5be0815dd424"); + }); +}); diff --git a/tests/qgis-projects/tests/layer_order.qgs b/tests/qgis-projects/tests/layer_order.qgs index b1013ad785..417287e63f 100644 --- a/tests/qgis-projects/tests/layer_order.qgs +++ b/tests/qgis-projects/tests/layer_order.qgs @@ -1,4 +1,4 @@ - + @@ -16,6 +16,7 @@ false + @@ -58,9 +59,9 @@ - + @@ -117,7 +118,7 @@ - + Annotations_8c76dc69_c826_44e6_beeb_c451216888cd @@ -145,6 +146,7 @@ + @@ -163,12 +165,21 @@ + + 1 + 1 + 1 + 0 + + + + 1 0 - + 3.80707036695971279 43.56670409545019851 @@ -218,6 +229,7 @@ + @@ -259,7 +271,7 @@ 1 0 - + @@ -282,7 +294,7 @@ - + @@ -331,7 +343,7 @@ - + @@ -364,7 +376,7 @@ - + @@ -407,7 +419,7 @@ - + @@ -434,14 +446,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + 0 @@ -460,7 +508,7 @@ - + @@ -524,35 +572,35 @@ - + - + - + - + - + @@ -567,6 +615,13 @@ + + + + + + + @@ -654,9 +709,9 @@ def my_form_open(dialog, layer, feature): "quartmno" - + - + 765145.88230000005569309 6274561.22229999955743551 @@ -706,6 +761,7 @@ def my_form_open(dialog, layer, feature): + @@ -770,7 +826,7 @@ def my_form_open(dialog, layer, feature): - + @@ -819,7 +875,7 @@ def my_form_open(dialog, layer, feature): - + @@ -852,7 +908,7 @@ def my_form_open(dialog, layer, feature): - + @@ -895,7 +951,7 @@ def my_form_open(dialog, layer, feature): - + @@ -922,12 +978,15 @@ def my_form_open(dialog, layer, feature): + + + - + @@ -937,7 +996,7 @@ def my_form_open(dialog, layer, feature): - + @@ -976,7 +1035,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1032,7 +1091,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1069,7 +1128,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1133,35 +1192,35 @@ def my_form_open(dialog, layer, feature): - + - + - + - + - + @@ -1176,6 +1235,13 @@ def my_form_open(dialog, layer, feature): + + + + + + + @@ -1263,9 +1329,9 @@ def my_form_open(dialog, layer, feature): "quartmno" - + - + 760748.21375807060394436 6280073.41499996930360794 @@ -1315,6 +1381,7 @@ def my_form_open(dialog, layer, feature): + @@ -1379,7 +1446,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1428,7 +1495,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1461,7 +1528,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1504,7 +1571,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1547,6 +1614,9 @@ def my_form_open(dialog, layer, feature): + + + @@ -1570,7 +1640,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1628,7 +1698,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1639,6 +1709,9 @@ def my_form_open(dialog, layer, feature): + + + @@ -1698,9 +1771,9 @@ def my_form_open(dialog, layer, feature): "id_line" - + - + 760946.65125827305018902 6280139.56083337031304836 @@ -1750,6 +1823,7 @@ def my_form_open(dialog, layer, feature): + @@ -1814,7 +1888,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1863,7 +1937,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1896,7 +1970,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1939,7 +2013,7 @@ def my_form_open(dialog, layer, feature): - + @@ -1974,6 +2048,9 @@ def my_form_open(dialog, layer, feature): + + + @@ -1997,7 +2074,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2055,7 +2132,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2066,6 +2143,9 @@ def my_form_open(dialog, layer, feature): + + + @@ -2125,7 +2205,7 @@ def my_form_open(dialog, layer, feature): "id_stop" - + @@ -2164,6 +2244,7 @@ def my_form_open(dialog, layer, feature): 5 2.5 + false false false 1 @@ -2286,6 +2367,9 @@ def my_form_open(dialog, layer, feature): + + + nboisteault 2023-08-17T11:45:34 @@ -2303,7 +2387,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2349,7 +2433,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2375,7 +2459,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2410,9 +2494,10 @@ 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."],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 @@ -2426,7 +2511,7 @@ def my_form_open(dialog, layer, feature): - + @@ -2477,4 +2562,7 @@ def my_form_open(dialog, layer, feature): - + + + + \ No newline at end of file diff --git a/tests/qgis-projects/tests/layer_order.qgs.cfg b/tests/qgis-projects/tests/layer_order.qgs.cfg index 6a72176382..2bac1a9a8d 100644 --- a/tests/qgis-projects/tests/layer_order.qgs.cfg +++ b/tests/qgis-projects/tests/layer_order.qgs.cfg @@ -1,14 +1,17 @@ { "metadata": { - "qgis_desktop_version": 32815, - "lizmap_plugin_version_str": "4.2.1-alpha", - "lizmap_plugin_version": 40201, - "lizmap_web_client_target_version": 30800, + "qgis_desktop_version": 33413, + "lizmap_plugin_version_str": "4.4.7-alpha", + "lizmap_plugin_version": 40407, + "lizmap_web_client_target_version": 31000, "lizmap_web_client_target_status": "Dev", "instance_target_url": "http://localhost:8130/", "instance_target_repository": "testsrepository" }, "warnings": {}, + "debug": { + "total_time": 0.733 + }, "options": { "projection": { "proj4": "+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", @@ -42,6 +45,7 @@ "pointTolerance": 25, "lineTolerance": 10, "polygonTolerance": 5, + "automatic_permalink": false, "tmTimeFrameSize": 10, "tmTimeFrameType": "seconds", "tmAnimationFrameLength": 1000, @@ -69,7 +73,7 @@ "minScale": 1, "maxScale": 1000000000000, "toggled": "True", - "popup": "False", + "popup": "True", "popupSource": "auto", "popupTemplate": "", "popupMaxFeatures": 10, @@ -103,7 +107,7 @@ "minScale": 1, "maxScale": 1000000000000, "toggled": "True", - "popup": "False", + "popup": "True", "popupSource": "auto", "popupTemplate": "", "popupMaxFeatures": 10, @@ -163,7 +167,7 @@ "minScale": 1, "maxScale": 1000000000000, "toggled": "True", - "popup": "False", + "popup": "True", "popupSource": "auto", "popupTemplate": "", "popupMaxFeatures": 10, @@ -197,7 +201,7 @@ "minScale": 1, "maxScale": 1000000000000, "toggled": "True", - "popup": "False", + "popup": "True", "popupSource": "auto", "popupTemplate": "", "popupMaxFeatures": 10,