From 0ed9f83afacf0200d62bfd59b06d273c57cb48a9 Mon Sep 17 00:00:00 2001 From: Boubrid Ihab Date: Mon, 20 Jun 2022 12:19:16 +0100 Subject: feature: max zoom on map --- modern/src/common/attributes/useCommonUserAttributes.js | 4 ++-- modern/src/map/core/MapView.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'modern') diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js index da19885e..1409c5ac 100644 --- a/modern/src/common/attributes/useCommonUserAttributes.js +++ b/modern/src/common/attributes/useCommonUserAttributes.js @@ -64,12 +64,12 @@ export default (t) => useMemo(() => ({ 'web.selectZoom': { name: t('attributeWebSelectZoom'), type: 'number', - }, + }, */ 'web.maxZoom': { name: t('attributeWebMaxZoom'), type: 'number', }, - 'ui.hidePositionAttributes': { + /* 'ui.hidePositionAttributes': { name: t('attributeUiHidePositionAttributes'), type: 'string', }, */ diff --git a/modern/src/map/core/MapView.js b/modern/src/map/core/MapView.js index 20e84185..f7d62c77 100644 --- a/modern/src/map/core/MapView.js +++ b/modern/src/map/core/MapView.js @@ -78,6 +78,11 @@ const MapView = ({ children }) => { const [activeMapStyles] = usePersistedState('activeMapStyles', ['locationIqStreets', 'osm', 'carto']); const [defaultMapStyle] = usePersistedState('selectedMapStyle', 'locationIqStreets'); const mapboxAccessToken = useAttributePreference('mapboxAccessToken'); + const maxZoom = useAttributePreference('web.maxZoom') || 16; + + useEffect(() => { + map.setMaxZoom(maxZoom); + }, [maxZoom]); useEffect(() => { maplibregl.accessToken = mapboxAccessToken; -- cgit v1.2.3 From ed45e941141c7ea2f0fc767946e23e476546c67d Mon Sep 17 00:00:00 2001 From: Boubrid Ihab Date: Mon, 20 Jun 2022 23:28:26 +0100 Subject: remove hardcoded default value --- modern/src/map/core/MapView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modern') diff --git a/modern/src/map/core/MapView.js b/modern/src/map/core/MapView.js index f7d62c77..38191a94 100644 --- a/modern/src/map/core/MapView.js +++ b/modern/src/map/core/MapView.js @@ -78,7 +78,7 @@ const MapView = ({ children }) => { const [activeMapStyles] = usePersistedState('activeMapStyles', ['locationIqStreets', 'osm', 'carto']); const [defaultMapStyle] = usePersistedState('selectedMapStyle', 'locationIqStreets'); const mapboxAccessToken = useAttributePreference('mapboxAccessToken'); - const maxZoom = useAttributePreference('web.maxZoom') || 16; + const maxZoom = useAttributePreference('web.maxZoom'); useEffect(() => { map.setMaxZoom(maxZoom); -- cgit v1.2.3 From 0e1686decab32ebed5b7af3e37d381ad8b5ee5c4 Mon Sep 17 00:00:00 2001 From: Boubrid Ihab Date: Tue, 21 Jun 2022 23:59:43 +0100 Subject: check if maxZoom has value before using it --- modern/src/map/core/MapView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modern') diff --git a/modern/src/map/core/MapView.js b/modern/src/map/core/MapView.js index 38191a94..98865157 100644 --- a/modern/src/map/core/MapView.js +++ b/modern/src/map/core/MapView.js @@ -81,7 +81,9 @@ const MapView = ({ children }) => { const maxZoom = useAttributePreference('web.maxZoom'); useEffect(() => { - map.setMaxZoom(maxZoom); + if (maxZoom) { + map.setMaxZoom(maxZoom); + } }, [maxZoom]); useEffect(() => { -- cgit v1.2.3