diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 0366d4cb..7b638618 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -125,18 +125,12 @@ U.Map = L.Map.extend({ // To be used in javascript APIs if (geojson.properties.lang) L.lang = geojson.properties.lang - // Don't let default autocreation of controls - const zoomControl = - typeof geojson.properties.zoomControl !== 'undefined' - ? geojson.properties.zoomControl - : true - geojson.properties.zoomControl = false - const fullscreenControl = - typeof geojson.properties.fullscreenControl !== 'undefined' - ? geojson.properties.fullscreenControl - : true - geojson.properties.fullscreenControl = false this.setOptionsFromQueryString(geojson.properties) + // Prevent default creation of controls + const zoomControl = geojson.properties.zoomControl + const fullscreenControl = geojson.properties.fullscreenControl + geojson.properties.zoomControl = false + geojson.properties.fullscreenControl = false L.Map.prototype.initialize.call(this, el, geojson.properties) U.DEFAULT_ICON_URL = this.options.default_iconUrl diff --git a/umap/tests/integration/test_querystring.py b/umap/tests/integration/test_querystring.py index 5118fe6c..92962ded 100644 --- a/umap/tests/integration/test_querystring.py +++ b/umap/tests/integration/test_querystring.py @@ -50,3 +50,17 @@ def test_can_deactivate_wheel_from_query_string(map, live_server, page): expect(page).to_have_url(re.compile(r".*#7/.+")) page.mouse.wheel(0, 1) expect(page).to_have_url(re.compile(r".*#7/.+")) + + +def test_zoom_control(map, live_server, datalayer, page): + control = page.locator(".leaflet-control-zoom") + page.goto(f"{live_server.url}{map.get_absolute_url()}") + expect(control).to_be_visible() + page.goto(f"{live_server.url}{map.get_absolute_url()}?zoomControl=false") + expect(control).to_be_hidden() + page.goto(f"{live_server.url}{map.get_absolute_url()}?zoomControl=true") + expect(control).to_be_visible() + page.goto(f"{live_server.url}{map.get_absolute_url()}?zoomControl=null") + expect(control).to_be_hidden() + page.get_by_title("More controls").click() + expect(control).to_be_visible()