mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 11:32:38 +02:00
fix: fix error when saving and deleting heatmap layer
Co-authored-by: David Larlet <david@larlet.fr>
This commit is contained in:
parent
f01a74f19f
commit
fab0c8f9ea
4 changed files with 1091 additions and 1 deletions
|
@ -614,7 +614,7 @@ class Feature {
|
||||||
this.datalayer.hideFeature(this)
|
this.datalayer.hideFeature(this)
|
||||||
this.makeUI()
|
this.makeUI()
|
||||||
this.datalayer.showFeature(this)
|
this.datalayer.showFeature(this)
|
||||||
} else {
|
} else if (this.datalayer?.isBrowsable()) {
|
||||||
this.ui._redraw()
|
this.ui._redraw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,11 @@ export const Heat = L.HeatLayer.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeLayer: (layer) => {
|
||||||
|
// No op, there is no "removeLatLng" in Leaflet.heat
|
||||||
|
// but this method is expected by DataLayer
|
||||||
|
},
|
||||||
|
|
||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
LayerMixin.onAdd.call(this, map)
|
LayerMixin.onAdd.call(this, map)
|
||||||
return L.HeatLayer.prototype.onAdd.call(this, map)
|
return L.HeatLayer.prototype.onAdd.call(this, map)
|
||||||
|
|
1044
umap/tests/fixtures/heatmap_data.json
vendored
Normal file
1044
umap/tests/fixtures/heatmap_data.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
41
umap/tests/integration/test_heatmap.py
Normal file
41
umap/tests/integration/test_heatmap.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from playwright.sync_api import expect
|
||||||
|
|
||||||
|
from ..base import DataLayerFactory
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
|
def test_heatmap(map, live_server, page):
|
||||||
|
path = Path(__file__).parent.parent / "fixtures/heatmap_data.json"
|
||||||
|
data = json.loads(path.read_text())
|
||||||
|
DataLayerFactory(data=data, map=map)
|
||||||
|
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||||
|
expect(page.locator("canvas.leaflet-heatmap-layer")).to_be_visible()
|
||||||
|
|
||||||
|
|
||||||
|
def test_can_create_heatmap_after_import(live_server, page, tilelayer, settings):
|
||||||
|
settings.UMAP_ALLOW_ANONYMOUS = True
|
||||||
|
page.goto(f"{live_server.url}/en/map/new")
|
||||||
|
page.get_by_title("Import data").click()
|
||||||
|
file_input = page.locator("input[type='file']")
|
||||||
|
with page.expect_file_chooser() as fc_info:
|
||||||
|
file_input.click()
|
||||||
|
file_chooser = fc_info.value
|
||||||
|
path = Path(__file__).parent.parent / "fixtures/heatmap_data.json"
|
||||||
|
file_chooser.set_files(path)
|
||||||
|
page.get_by_role("button", name="Import data", exact=True).click()
|
||||||
|
page.get_by_role("button", name="Manage layers").click()
|
||||||
|
page.get_by_role("button", name="Edit", exact=True).click()
|
||||||
|
page.get_by_role("combobox").select_option("Heat")
|
||||||
|
page.get_by_role("button", name="Save draft").click()
|
||||||
|
expect(page.locator("canvas.leaflet-heatmap-layer")).to_be_visible()
|
||||||
|
|
||||||
|
# Test we can delete it and save
|
||||||
|
page.get_by_text("Advanced actions").click()
|
||||||
|
page.get_by_role("button", name="Delete").click()
|
||||||
|
page.get_by_role("button", name="Save draft").click()
|
||||||
|
expect(page.locator("canvas.leaflet-heatmap-layer")).to_be_hidden()
|
Loading…
Reference in a new issue