Skip to content

Commit

Permalink
Embed URL param
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed May 19, 2024
1 parent 9f5afa4 commit 23b3890
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,39 @@ class EventMap {

this.map.touchZoomRotate.disableRotation()

this.map.addControl(new maplibregl.NavigationControl(), 'top-right')

this.map.addControl(
new maplibregl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true,
},
trackUserLocation: true,
})
)

this.map.addControl(
new maplibregl.ScaleControl({
maxWidth: 200,
unit: 'metric',
})
)

this.map.addControl(new DistanceMeasure(), 'top-right')
this.map.addControl(new InstallControl(), 'top-left')

this.map.addControl(new VillagesEditor('villages', 'villages_symbol'), 'top-right')

// Display edit control only on browsers which are likely to be desktop browsers
if (window.matchMedia('(min-width: 600px)').matches) {
this.map.addControl(new ExportControl(loadIcons), 'top-right')
const url = new URL(window.location.href)
const embed = url.searchParams.get('embed') == 'true'

if (!embed) {
this.map.addControl(new maplibregl.NavigationControl(), 'top-right')

this.map.addControl(
new maplibregl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true,
},
trackUserLocation: true,
})
)

this.map.addControl(
new maplibregl.ScaleControl({
maxWidth: 200,
unit: 'metric',
})
)

this.map.addControl(new DistanceMeasure(), 'top-right')
this.map.addControl(new InstallControl(), 'top-left')

this.map.addControl(new VillagesEditor('villages', 'villages_symbol'), 'top-right')

// Display edit control only on browsers which are likely to be desktop browsers
if (window.matchMedia('(min-width: 600px)').matches) {
this.map.addControl(new ExportControl(loadIcons), 'top-right')
}
} else {
document.querySelector('header')!.style.display = 'none'
}

this.map.addControl(this.layer_switcher, 'top-right')
Expand Down

0 comments on commit 23b3890

Please sign in to comment.