Skip to content

Commit

Permalink
feat: show/hide map zoom controls
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Feb 26, 2024
1 parent 54cc5c7 commit 8cfa67b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/map.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import WebMap from '@arcgis/core/WebMap';
import MapView from '@arcgis/core/views/MapView';
import { mediaQuery } from './utils';
import { mediaMinWidth, mediaQuery } from './utils';

function initMap() {
mediaQuery('(prefers-color-scheme: dark)', (result) => {
Expand All @@ -13,10 +13,21 @@ function initMap() {
},
});

new MapView({
const view = new MapView({
map: map,
container: 'viewDiv',
zoom: 5,
ui: {
components: ['attribution'],
},
});

mediaMinWidth('m', (result) => {
if (result.matches) {
view.ui.components = ['attribution', 'zoom'];
} else {
view.ui.components = ['attribution'];
}
});

map.when(() => {
Expand Down

0 comments on commit 8cfa67b

Please sign in to comment.