Skip to content

Commit

Permalink
Remove previous image when panning in templated image layer
Browse files Browse the repository at this point in the history
  • Loading branch information
prushforth committed Jun 2, 2023
1 parent d08d72e commit 7b0858f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mapml/layers/TemplatedImageLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export var TemplatedImageLayer = L.Layer.extend({

_addImage: function (bounds, zoom, loc) {
let map = this._map;
let overlayToRemove = this._imageLayer;
let overlayToRemove = this._imageOverlay;
let src = this.getImageUrl(bounds, zoom);
let size = map.getSize();
this._imageOverlay = M.imageLayer(src, loc, size, 0, this._container);
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/layers/templatedImageLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ test.describe('Playwright templatedImage Layer Tests', () => {
};
expect(imagePos).toEqual(expectedPos);
});
test('Templated image layer - remove previous image on moveend', async () => {
await page.click('body > map');
// generate a few map moves
await page.keyboard.press('ArrowUp');
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('ArrowRight');
await page.keyboard.press('ArrowDown');
await page.waitForLoadState('networkidle');
const images = await page.locator(
'.mapml-templatedlayer-container > .mapml-image-container > .leaflet-image-loaded'
);
await expect(images).toHaveCount(1);
});
});

0 comments on commit 7b0858f

Please sign in to comment.