feat: open popup when default view is set to latest

fix #1726
This commit is contained in:
Yohan Boniface 2024-04-16 14:52:52 +02:00
parent 05fd33deb7
commit 4b05a62b8b
3 changed files with 8 additions and 9 deletions

View file

@ -310,13 +310,13 @@ U.FeatureMixin = {
zoomTo: function (e) { zoomTo: function (e) {
e = e || {} e = e || {}
const easing = e.easing !== undefined ? e.easing : this.map.getOption('easing') const easing = e.easing !== undefined ? e.easing : this.map.getOption('easing')
if (e.callback) this.map.once('moveend', e.callback.call(this))
if (easing) { if (easing) {
this.map.flyTo(this.getCenter(), this.getBestZoom()) this.map.flyTo(this.getCenter(), this.getBestZoom())
} else { } else {
const latlng = e.latlng || this.getCenter() const latlng = e.latlng || this.getCenter()
this.map.setView(latlng, this.getBestZoom() || this.map.getZoom()) this.map.setView(latlng, this.getBestZoom() || this.map.getZoom())
} }
if (e.callback) e.callback.call(this)
}, },
getBestZoom: function () { getBestZoom: function () {

View file

@ -82,7 +82,6 @@ U.Map = L.Map.extend({
.split(',') .split(',')
} }
let editedFeature = null let editedFeature = null
const self = this const self = this
try { try {
@ -334,7 +333,6 @@ U.Map = L.Map.extend({
if (this.options.editMode === 'advanced') { if (this.options.editMode === 'advanced') {
new U.SettingsToolbar({ actions: editActions }).addTo(this) new U.SettingsToolbar({ actions: editActions }).addTo(this)
} }
} }
this._controls.zoom = new L.Control.Zoom({ this._controls.zoom = new L.Control.Zoom({
zoomInTitle: L._('Zoom in'), zoomInTitle: L._('Zoom in'),
@ -388,7 +386,7 @@ U.Map = L.Map.extend({
document.body, document.body,
'umap-caption-bar-enabled', 'umap-caption-bar-enabled',
this.options.captionBar || this.options.captionBar ||
(this.options.slideshow && this.options.slideshow.active) (this.options.slideshow && this.options.slideshow.active)
) )
L.DomUtil.classIf( L.DomUtil.classIf(
document.body, document.body,
@ -716,7 +714,7 @@ U.Map = L.Map.extend({
if (datalayer) { if (datalayer) {
const feature = datalayer.getFeatureByIndex(-1) const feature = datalayer.getFeatureByIndex(-1)
if (feature) { if (feature) {
feature.zoomTo() feature.zoomTo({ callback: this.options.noControl ? null : feature.view })
return return
} }
} }
@ -1582,10 +1580,10 @@ U.Map = L.Map.extend({
initCaptionBar: function () { initCaptionBar: function () {
const container = L.DomUtil.create( const container = L.DomUtil.create(
'div', 'div',
'umap-caption-bar', 'umap-caption-bar',
this._controlContainer this._controlContainer
), ),
name = L.DomUtil.create('h3', '', container) name = L.DomUtil.create('h3', '', container)
L.DomEvent.disableClickPropagation(container) L.DomEvent.disableClickPropagation(container)
this.permissions.addOwnerLink('span', container) this.permissions.addOwnerLink('span', container)

View file

@ -85,6 +85,7 @@ def test_default_view_latest_with_marker(map, live_server, datalayer, page):
expect(page).to_have_url(re.compile(r".*#7/48\..+/14\..+")) expect(page).to_have_url(re.compile(r".*#7/48\..+/14\..+"))
layers = page.locator(".umap-browser .datalayer h5") layers = page.locator(".umap-browser .datalayer h5")
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(page.locator(".leaflet-popup")).to_be_visible()
def test_default_view_latest_with_line(map, live_server, page): def test_default_view_latest_with_line(map, live_server, page):