mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
Merge pull request #2129 from umap-project/fix-cluster-browser-view
fix: clicking feature in the browser would not open popup in cluster
This commit is contained in:
commit
51c1fb0a8f
3 changed files with 57 additions and 4 deletions
|
@ -45,7 +45,7 @@ export default class Browser {
|
||||||
Icon.setContrast(icon, colorBox, symbol, bgcolor)
|
Icon.setContrast(icon, colorBox, symbol, bgcolor)
|
||||||
}
|
}
|
||||||
const viewFeature = (e) => {
|
const viewFeature = (e) => {
|
||||||
feature.zoomTo({ ...e, callback: feature.view })
|
feature.zoomTo({ ...e, callback: () => feature.view() })
|
||||||
}
|
}
|
||||||
DomEvent.on(zoom_to, 'click', viewFeature)
|
DomEvent.on(zoom_to, 'click', viewFeature)
|
||||||
DomEvent.on(title, 'click', viewFeature)
|
DomEvent.on(title, 'click', viewFeature)
|
||||||
|
|
|
@ -439,7 +439,7 @@ class Feature {
|
||||||
|
|
||||||
zoomTo({ easing, latlng, callback } = {}) {
|
zoomTo({ easing, latlng, callback } = {}) {
|
||||||
if (easing === undefined) easing = this.map.getOption('easing')
|
if (easing === undefined) easing = this.map.getOption('easing')
|
||||||
if (callback) this.map.once('moveend', callback.call(this))
|
if (callback) this.map.once('moveend', callback.bind(this))
|
||||||
if (easing) {
|
if (easing) {
|
||||||
this.map.flyTo(this.center, this.getBestZoom())
|
this.map.flyTo(this.center, this.getBestZoom())
|
||||||
} else {
|
} else {
|
||||||
|
@ -663,9 +663,9 @@ export class Point extends Feature {
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomTo(event) {
|
zoomTo(event) {
|
||||||
if (this.datalayer.isClustered() && !this._icon) {
|
if (this.datalayer.isClustered() && !this.ui._icon) {
|
||||||
// callback is mandatory for zoomToShowLayer
|
// callback is mandatory for zoomToShowLayer
|
||||||
this.datalayer.layer.zoomToShowLayer(this, event.callback || (() => {}))
|
this.datalayer.layer.zoomToShowLayer(this.ui, event.callback || (() => {}))
|
||||||
} else {
|
} else {
|
||||||
super.zoomTo(event)
|
super.zoomTo(event)
|
||||||
}
|
}
|
||||||
|
|
53
umap/tests/integration/test_cluster.py
Normal file
53
umap/tests/integration/test_cluster.py
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
import pytest
|
||||||
|
from playwright.sync_api import expect
|
||||||
|
|
||||||
|
from ..base import DataLayerFactory
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
|
DATALAYER_DATA = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"_umap_options": {
|
||||||
|
"name": "Calque 1",
|
||||||
|
"type": "Cluster",
|
||||||
|
"cluster": {},
|
||||||
|
"browsable": True,
|
||||||
|
"inCaption": True,
|
||||||
|
"displayOnLoad": True,
|
||||||
|
},
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"properties": {"name": "one point in france"},
|
||||||
|
"geometry": {"type": "Point", "coordinates": [3.339844, 46.920255]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"properties": {
|
||||||
|
"name": "one another point in france in same position",
|
||||||
|
"description": "can you see me ?",
|
||||||
|
},
|
||||||
|
"geometry": {"type": "Point", "coordinates": [3.339844, 46.920255]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"properties": {
|
||||||
|
"name": "again one another point",
|
||||||
|
"description": "and me ?",
|
||||||
|
},
|
||||||
|
"geometry": {"type": "Point", "coordinates": [3.34, 46.1]},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_can_open_feature_on_browser_click(live_server, page, map):
|
||||||
|
map.settings["properties"]["onLoadPanel"] = "databrowser"
|
||||||
|
map.save()
|
||||||
|
DataLayerFactory(map=map, data=DATALAYER_DATA)
|
||||||
|
page.goto(f"{live_server.url}{map.get_absolute_url()}#7/46.920/3.340")
|
||||||
|
page.get_by_text("one another point in france in same position").click()
|
||||||
|
expect(page.get_by_text("can you see me ?")).to_be_visible()
|
||||||
|
page.get_by_text("again one another point").click()
|
||||||
|
expect(page.get_by_text("and me ?")).to_be_visible()
|
Loading…
Reference in a new issue