mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 11:32:38 +02:00
feat: allow to hide the back to home button (#2638)
This commit is contained in:
commit
ef072f0a8e
4 changed files with 15 additions and 11 deletions
|
@ -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 () {
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue