diff --git a/umap/static/umap/js/modules/rendering/map.js b/umap/static/umap/js/modules/rendering/map.js index cbfe1ccc..b5f5d5ae 100644 --- a/umap/static/umap/js/modules/rendering/map.js +++ b/umap/static/umap/js/modules/rendering/map.js @@ -23,6 +23,7 @@ BaseMap.mergeOptions({ const ControlsMixin = { HIDDABLE_CONTROLS: [ + 'home', 'zoom', 'search', 'fullscreen', @@ -41,6 +42,7 @@ const ControlsMixin = { if (this._umap.hasEditMode() && !this.options.noControl) { new U.EditControl(this).addTo(this) } + this._controls.home = new U.HomeControl(this._umap) this._controls.zoom = new Control.Zoom({ zoomInTitle: translate('Zoom in'), zoomOutTitle: translate('Zoom out'), @@ -91,10 +93,6 @@ const ControlsMixin = { } if (this.options.noControl) return - // Do not display in an iframe. - if (window.self === window.top) { - this._controls.home = new U.HomeControl().addTo(this) - } this._controls.attribution = new U.AttributionControl().addTo(this) if (this.options.miniMap) { this.whenReady(function () { diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 900243d8..099a59d3 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -204,6 +204,12 @@ export const SCHEMA = { type: Object, impacts: ['data'], }, + homeControl: { + type: Boolean, + impacts: ['ui'], + label: translate('Display the back to home icon'), + default: true, + }, iconClass: { type: String, impacts: ['data'], diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index f7dfeaef..3f3b330d 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -106,6 +106,11 @@ export default class Umap { if (geojson.properties.schema) this.overrideSchema(geojson.properties.schema) + // Do not display in an iframe. + if (window.self !== window.top) { + geojson.properties.homeControl = false + } + this._leafletMap.setup() this.panel = new Panel(this, this._leafletMap) @@ -828,6 +833,7 @@ export default class Umap { UIFields.push(`properties.${name}Control`) } UIFields = UIFields.concat([ + 'properties.homeControl', 'properties.moreControl', 'properties.scrollWheelZoom', 'properties.miniMap', diff --git a/umap/tests/integration/test_edit_map.py b/umap/tests/integration/test_edit_map.py index 571829bf..02744d2e 100644 --- a/umap/tests/integration/test_edit_map.py +++ b/umap/tests/integration/test_edit_map.py @@ -69,13 +69,7 @@ def test_zoomcontrol_impacts_ui(live_server, page, tilelayer): # Hide them page.get_by_text("User interface options").click() - hide_zoom_controls = ( - page.locator(".panel") - .filter(has_text=re.compile("Display the zoom control")) - .locator("label") - .nth(2) - ) - hide_zoom_controls.click() + page.locator(".panel .umap-field-zoomControl").get_by_text("never").click() expect(zoom_in).to_be_hidden() expect(zoom_out).to_be_hidden()