forked from MapComplete/MapComplete
Chore: housekeeping
This commit is contained in:
parent
8178c5607b
commit
cd0d275965
73 changed files with 2105 additions and 2219 deletions
|
|
@ -20,8 +20,6 @@
|
|||
$: iconItem = icon.icon?.GetRenderValue($tags)?.Subs($tags)?.txt
|
||||
let color = icon.color?.GetRenderValue($tags)?.txt ?? "#000000"
|
||||
$: color = icon.color?.GetRenderValue($tags)?.txt ?? "#000000"
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{#if iconItem?.startsWith("<")}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
|||
readonly allowMoving: UIEventSource<true | boolean | undefined>
|
||||
readonly allowRotating: UIEventSource<true | boolean | undefined>
|
||||
readonly allowZooming: UIEventSource<true | boolean | undefined>
|
||||
readonly lastClickLocation: Store<undefined | { lon: number; lat: number, mode : "left" | "right" | "middle" }>
|
||||
readonly lastClickLocation: Store<
|
||||
undefined | { lon: number; lat: number; mode: "left" | "right" | "middle" }
|
||||
>
|
||||
readonly minzoom: UIEventSource<number>
|
||||
readonly maxzoom: UIEventSource<number>
|
||||
readonly rotation: UIEventSource<number>
|
||||
|
|
@ -70,7 +72,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
|||
this.location.setData({ ...this.location.data })
|
||||
}
|
||||
this.zoom = state?.zoom ?? new UIEventSource(1)
|
||||
this.minzoom = state?.minzoom ?? new UIEventSource(0.5)// 0.5 is the maplibre minzoom
|
||||
this.minzoom = state?.minzoom ?? new UIEventSource(0.5) // 0.5 is the maplibre minzoom
|
||||
this.maxzoom = state?.maxzoom ?? new UIEventSource(24)
|
||||
this.zoom.addCallbackAndRunD((z) => {
|
||||
if (z < this.minzoom.data) {
|
||||
|
|
@ -92,13 +94,17 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
|||
this.rasterLayer =
|
||||
state?.rasterLayer ?? new UIEventSource<RasterLayerPolygon | undefined>(undefined)
|
||||
|
||||
const lastClickLocation = new UIEventSource<{lat:number,lon:number,mode: "left" | "right" | "middle"}>(undefined)
|
||||
const lastClickLocation = new UIEventSource<{
|
||||
lat: number
|
||||
lon: number
|
||||
mode: "left" | "right" | "middle"
|
||||
}>(undefined)
|
||||
this.lastClickLocation = lastClickLocation
|
||||
const self = this
|
||||
|
||||
new RasterLayerHandler(this._maplibreMap, this.rasterLayer)
|
||||
|
||||
const clickmodes = ["left" , "middle", "right"] as const
|
||||
const clickmodes = ["left", "middle", "right"] as const
|
||||
function handleClick(e: maplibregl.MapMouseEvent, mode?: "left" | "right" | "middle") {
|
||||
if (e.originalEvent["consumed"]) {
|
||||
// Workaround, 'ShowPointLayer' sets this flag
|
||||
|
|
@ -148,8 +154,8 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
|||
})
|
||||
|
||||
map._container.addEventListener("contextmenu", (e) => {
|
||||
const lngLat = map.unproject([e.x, e.y])
|
||||
lastClickLocation.setData({lon: lngLat.lng, lat: lngLat.lat, mode: "right"})
|
||||
const lngLat = map.unproject([e.x, e.y])
|
||||
lastClickLocation.setData({ lon: lngLat.lng, lat: lngLat.lat, mode: "right" })
|
||||
})
|
||||
map.on("dblclick", (e) => {
|
||||
handleClick(e, "left")
|
||||
|
|
@ -675,5 +681,4 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
let _map: Map
|
||||
onMount(() => {
|
||||
|
||||
const { lon, lat } = mapProperties?.location?.data ?? { lon: 0, lat: 0 }
|
||||
|
||||
const rasterLayer: RasterLayerProperties = mapProperties?.rasterLayer?.data?.properties
|
||||
|
|
@ -73,11 +72,10 @@
|
|||
})
|
||||
onDestroy(async () => {
|
||||
await Utils.waitFor(250)
|
||||
try{
|
||||
|
||||
if (_map) _map.remove()
|
||||
map = null
|
||||
}catch (e) {
|
||||
try {
|
||||
if (_map) _map.remove()
|
||||
map = null
|
||||
} catch (e) {
|
||||
console.error("Could not destroy map")
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -8,19 +8,21 @@
|
|||
export let icons: string | { icon: string; color: string }[]
|
||||
|
||||
let iconsParsed: { icon: string; color: string }[]
|
||||
if(typeof icons === "string") {
|
||||
iconsParsed = icons.split(";").map(subspec => {
|
||||
if(subspec.startsWith("http://") || subspec.startsWith("https://")){
|
||||
if (typeof icons === "string") {
|
||||
iconsParsed = icons.split(";").map((subspec) => {
|
||||
if (subspec.startsWith("http://") || subspec.startsWith("https://")) {
|
||||
return {
|
||||
icon: subspec, color: "black"
|
||||
icon: subspec,
|
||||
color: "black",
|
||||
}
|
||||
}
|
||||
const [icon, color] = subspec.split(":")
|
||||
return {
|
||||
icon, color: color ?? "black"
|
||||
icon,
|
||||
color: color ?? "black",
|
||||
}
|
||||
})
|
||||
}else{
|
||||
} else {
|
||||
iconsParsed = icons
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,10 +97,10 @@ class SingleBackgroundHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private tryEnableSafe(): boolean{
|
||||
private tryEnableSafe(): boolean {
|
||||
try {
|
||||
return this.tryEnable()
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.log("Error: could not enable due to error", e)
|
||||
return false
|
||||
}
|
||||
|
|
@ -119,11 +119,7 @@ class SingleBackgroundHandler {
|
|||
console.debug("Enabling", background.id)
|
||||
let addLayerBeforeId = "transit_pier" // this is the first non-landuse item in the stylesheet, we add the raster layer before the roads but above the landuse
|
||||
if (!map.getLayer(addLayerBeforeId)) {
|
||||
console.warn(
|
||||
"Layer",
|
||||
addLayerBeforeId,
|
||||
"not found"
|
||||
)
|
||||
console.warn("Layer", addLayerBeforeId, "not found")
|
||||
addLayerBeforeId = undefined
|
||||
}
|
||||
if (background.category === "osmbasedmap" || background.category === "map") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue