Skip to content

Commit cd8fd93

Browse files
authored
Merge pull request #5652 from rldhont/fix-regression-popup-geometry
Fix UI regression: Clear popup geometry
2 parents f24b395 + 3576843 commit cd8fd93

File tree

2 files changed

+91
-11
lines changed

2 files changed

+91
-11
lines changed

assets/src/legacy/map.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,9 @@ window.lizMap = function() {
840840
* @param {Array} coordinate - coordinate in map unit
841841
*/
842842
function displayGetFeatureInfo(text, xy, coordinate){
843+
// clear highlight layer
844+
lizMap.mainLizmap.map.clearHighlightFeatures();
845+
843846
var eventLonLatInfo = map.getLonLatFromPixel(xy);
844847

845848
var popup = null;
@@ -1492,28 +1495,29 @@ window.lizMap = function() {
14921495
}
14931496

14941497
// Create the dock if needed
1495-
if( 'popupLocation' in config.options &&
1496-
config.options.popupLocation != 'map' ) {
1498+
if( 'popupLocation' in config.options && config.options.popupLocation != 'map' ){
1499+
var popupContainerId = 'popupcontent';
14971500
if ( !$('#mapmenu .nav-list > li.popupcontent > a').length ) {
14981501
// Verifying the message
14991502
if ( !('popup.msg.start' in lizDict) )
15001503
lizDict['popup.msg.start'] = 'Click to the map to get informations.';
15011504
// Initialize dock
1502-
var popupContainerId = 'popupcontent';
15031505
var pcontent = '<div class="lizmapPopupContent"><h4>'+lizDict['popup.msg.start']+'</h4></div>';
15041506
addDock(popupContainerId, 'Popup', config.options.popupLocation, pcontent, 'icon-comment');
1505-
$('#button-popupcontent').click(function(){
1506-
if($(this).parent().hasClass('active')) {
1507-
// clear highlight layer
1508-
lizMap.mainLizmap.map.clearHighlightFeatures();
1509-
// remove information
1510-
$('#popupcontent > div.menu-content').html('<div class="lizmapPopupContent"><h4>'+lizDict['popup.msg.start']+'</h4></div>');
1511-
}
1512-
});
15131507
} else {
15141508
$('#mapmenu .nav-list > li.popupcontent > a > span.icon').append('<i class="icon-comment icon-white" style="margin-left: 4px;"></i>');
15151509
$('#mapmenu .nav-list > li.popupcontent > a > span.icon').css('background-image', 'none');
15161510
}
1511+
1512+
$('#button-popupcontent').click(function(){
1513+
if ($(this).parent().hasClass('active')) {
1514+
// clear highlight layer but keep information
1515+
lizMap.mainLizmap.map.clearHighlightFeatures();
1516+
} else {
1517+
// Display geometry associated with popups
1518+
addGeometryFeatureInfo(null, popupContainerId);
1519+
}
1520+
});
15171521
}
15181522

15191523
/**

tests/end2end/playwright/popup.spec.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,82 @@ test.describe('Popup',
430430
});
431431
});
432432

433+
test.describe('Popup Geometry',
434+
{
435+
tag: ['@readonly'],
436+
},() => {
437+
438+
test('Show/hide the geometry on open/close dock', async ({ page }) => {
439+
const project = new ProjectPage(page, 'feature_toolbar');
440+
await project.open();
441+
442+
// Get default buffer with one point
443+
let buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
444+
const defaultByteLength = buffer.byteLength;
445+
await expect(defaultByteLength).toBeGreaterThan(900); // 906
446+
await expect(defaultByteLength).toBeLessThan(1000) // 906
447+
448+
// Click on a point
449+
let getFeatureInfoPromise = project.waitForGetFeatureInfoRequest();
450+
await project.clickOnMap(436, 290);
451+
let getFeatureInfoRequest = await getFeatureInfoPromise;
452+
await getFeatureInfoRequest.response();
453+
454+
// The geometry is displayed
455+
buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
456+
await expect(buffer.byteLength).not.toBe(defaultByteLength);
457+
await expect(buffer.byteLength).toBeGreaterThan(defaultByteLength);
458+
459+
// Close popup
460+
page.locator('#button-popupcontent').click();
461+
await page.waitForTimeout(50);
462+
463+
buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
464+
await expect(buffer.byteLength).toBe(defaultByteLength);
465+
466+
// Open popup
467+
page.locator('#button-popupcontent').click();
468+
await page.waitForTimeout(50);
469+
470+
buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
471+
await expect(buffer.byteLength).not.toBe(defaultByteLength);
472+
await expect(buffer.byteLength).toBeGreaterThan(defaultByteLength);
473+
});
474+
475+
test('Show/hide the geometry on click on the map', async ({ page }) => {
476+
const project = new ProjectPage(page, 'feature_toolbar');
477+
await project.open();
478+
479+
// Get default buffer with one point
480+
let buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
481+
const defaultByteLength = buffer.byteLength;
482+
await expect(defaultByteLength).toBeGreaterThan(900); // 906
483+
await expect(defaultByteLength).toBeLessThan(1000) // 906
484+
485+
// Click on a point
486+
let getFeatureInfoPromise = project.waitForGetFeatureInfoRequest();
487+
await project.clickOnMap(436, 290);
488+
let getFeatureInfoRequest = await getFeatureInfoPromise;
489+
await getFeatureInfoRequest.response();
490+
491+
// The geometry is displayed
492+
buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
493+
await expect(buffer.byteLength).not.toBe(defaultByteLength);
494+
await expect(buffer.byteLength).toBeGreaterThan(defaultByteLength);
495+
496+
// Not click on a point
497+
getFeatureInfoPromise = project.waitForGetFeatureInfoRequest();
498+
await project.clickOnMap(536, 290);
499+
getFeatureInfoRequest = await getFeatureInfoPromise;
500+
await getFeatureInfoRequest.response();
501+
await page.waitForTimeout(500); // wait to be sure
502+
503+
// Nothing
504+
buffer = await page.screenshot({clip:{x:425, y:325, width:100, height:100}});
505+
await expect(buffer.byteLength).toBe(defaultByteLength);
506+
});
507+
});
508+
433509
test.describe('Children in popup', () => {
434510

435511
test.beforeEach(async ({ page }) => {

0 commit comments

Comments
 (0)