forked from MapComplete/MapComplete
Fix: fix showing splitpoint icons
This commit is contained in:
parent
cce74fc40a
commit
9da10a9b32
1 changed files with 8 additions and 9 deletions
|
@ -26,6 +26,7 @@
|
||||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||||
import SmallZoomButtons from "../Map/SmallZoomButtons.svelte"
|
import SmallZoomButtons from "../Map/SmallZoomButtons.svelte"
|
||||||
import CompassWidget from "./CompassWidget.svelte"
|
import CompassWidget from "./CompassWidget.svelte"
|
||||||
|
import type { OsmTags } from "../../Models/OsmFeature"
|
||||||
|
|
||||||
const splitpoint_style = new LayerConfig(
|
const splitpoint_style = new LayerConfig(
|
||||||
<LayerConfigJson>split_point,
|
<LayerConfigJson>split_point,
|
||||||
|
@ -62,14 +63,14 @@
|
||||||
let map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined)
|
let map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined)
|
||||||
let adaptor = new MapLibreAdaptor(map, mapProperties)
|
let adaptor = new MapLibreAdaptor(map, mapProperties)
|
||||||
|
|
||||||
let wayGeojson: Feature<LineString> = <Feature<LineString>>osmWay.asGeoJson()
|
let wayGeojson: Feature<LineString, OsmTags> = <Feature<LineString, OsmTags>>osmWay.asGeoJson()
|
||||||
adaptor.location.setData(GeoOperations.centerpointCoordinatesObj(wayGeojson))
|
adaptor.location.setData(GeoOperations.centerpointCoordinatesObj(wayGeojson))
|
||||||
adaptor.bounds.setData(BBox.get(wayGeojson).pad(2))
|
adaptor.bounds.setData(BBox.get(wayGeojson).pad(2))
|
||||||
adaptor.maxbounds.setData(BBox.get(wayGeojson).pad(2))
|
adaptor.maxbounds.setData(BBox.get(wayGeojson).pad(2))
|
||||||
|
|
||||||
state?.showCurrentLocationOn(map)
|
state?.showCurrentLocationOn(map)
|
||||||
new ShowDataLayer(map, {
|
new ShowDataLayer(map, {
|
||||||
features: new StaticFeatureSource([wayGeojson]),
|
features: new StaticFeatureSource<Feature<LineString, { id: string }>>([wayGeojson]),
|
||||||
drawMarkers: true,
|
drawMarkers: true,
|
||||||
layer: layer,
|
layer: layer,
|
||||||
})
|
})
|
||||||
|
@ -80,8 +81,8 @@
|
||||||
{
|
{
|
||||||
id: string
|
id: string
|
||||||
index: number
|
index: number
|
||||||
dist: number
|
dist?: number
|
||||||
location: number
|
location?: number
|
||||||
}
|
}
|
||||||
>[]
|
>[]
|
||||||
> = new UIEventSource([])
|
> = new UIEventSource([])
|
||||||
|
@ -97,7 +98,7 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
splitPoints.data.splice(i, 1)
|
splitPoints.data.splice(i, 1)
|
||||||
splitPoints.ping()
|
splitPoints.update(ls => [...ls])
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let id = 0
|
let id = 0
|
||||||
|
@ -105,8 +106,7 @@
|
||||||
let projected: Feature<Point, { index: number; id: string; reuse?: string }> = <any>(
|
let projected: Feature<Point, { index: number; id: string; reuse?: string }> = <any>(
|
||||||
GeoOperations.nearestPoint(wayGeojson, [lon, lat])
|
GeoOperations.nearestPoint(wayGeojson, [lon, lat])
|
||||||
)
|
)
|
||||||
|
projected.properties.id = "" + id
|
||||||
console.log("Added splitpoint", projected, id)
|
|
||||||
|
|
||||||
// We check the next and the previous point. If those are closer then the tolerance, we reuse those instead
|
// We check the next and the previous point. If those are closer then the tolerance, we reuse those instead
|
||||||
|
|
||||||
|
@ -118,7 +118,6 @@
|
||||||
const previousPoint = <[number, number]>way[i]
|
const previousPoint = <[number, number]>way[i]
|
||||||
const previousDistance = GeoOperations.distanceBetween(previousPoint, p)
|
const previousDistance = GeoOperations.distanceBetween(previousPoint, p)
|
||||||
|
|
||||||
console.log("ND", nextDistance, "PD", previousDistance)
|
|
||||||
if (nextDistance <= snapTolerance && previousDistance >= nextDistance) {
|
if (nextDistance <= snapTolerance && previousDistance >= nextDistance) {
|
||||||
projected = {
|
projected = {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
|
@ -150,7 +149,7 @@
|
||||||
|
|
||||||
id++
|
id++
|
||||||
splitPoints.data.push(projected)
|
splitPoints.data.push(projected)
|
||||||
splitPoints.ping()
|
splitPoints.update(ls => [...ls])
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue