Skip to content

Commit

Permalink
Popup: respect popupMaxFeatures parameter (3liz#4537)
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault authored Jun 20, 2024
1 parent 30db326 commit 2c856a7
Show file tree
Hide file tree
Showing 4 changed files with 525 additions and 12 deletions.
6 changes: 5 additions & 1 deletion assets/src/modules/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default class Popup {
const filterTokens = [];
const legendOn = [];
const legendOff = [];
let popupMaxFeatures = 10;
for (const layer of candidateLayers) {
const layerWmsParams = layer.wmsParameters;
// Add layer to the list of layers
Expand All @@ -133,6 +134,9 @@ export default class Popup {
if ('LEGEND_OFF' in layerWmsParams) {
legendOff.push(layerWmsParams['LEGEND_OFF']);
}
if (layer.layerConfig.popupMaxFeatures > popupMaxFeatures) {
popupMaxFeatures = layer.layerConfig.popupMaxFeatures;
}
}

const wms = new WMS();
Expand All @@ -151,9 +155,9 @@ export default class Popup {
STYLE: layersStyles.join(','),
CRS: mainLizmap.projection,
BBOX: bbox,
FEATURE_COUNT: 10,
WIDTH: width,
HEIGHT: height,
FEATURE_COUNT: popupMaxFeatures,
I: Math.round(xCoord),
J: Math.round(yCoord),
FI_POINT_TOLERANCE: pointTolerance,
Expand Down
17 changes: 17 additions & 0 deletions tests/end2end/playwright/popup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,20 @@ test.describe('Popup config mocked with "minidock" option', () => {
await expect(page.locator('#mini-dock-content .lizmapPopupDiv')).toBeVisible();
});
});

test.describe('Popup max features', () => {
test('popupMaxFeatures param is respected', async ({ page }) => {
const url = '/index.php/view/map?repository=testsrepository&project=popup#-5.390390,35.762412,13.763671,50.710265|townhalls_pg|d%C3%A9faut|1';
await gotoMap(url, page);

await page.locator('#newOlMap').click({
position: {
x: 435,
y: 292
}
});

await expect(page.locator('.lizmapPopupSingleFeature')).toHaveCount(15);
});
});

Loading

0 comments on commit 2c856a7

Please sign in to comment.