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 SmallZoomButtons from "../Map/SmallZoomButtons.svelte"
|
||||
import CompassWidget from "./CompassWidget.svelte"
|
||||
import type { OsmTags } from "../../Models/OsmFeature"
|
||||
|
||||
const splitpoint_style = new LayerConfig(
|
||||
<LayerConfigJson>split_point,
|
||||
|
@ -62,14 +63,14 @@
|
|||
let map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined)
|
||||
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.bounds.setData(BBox.get(wayGeojson).pad(2))
|
||||
adaptor.maxbounds.setData(BBox.get(wayGeojson).pad(2))
|
||||
|
||||
state?.showCurrentLocationOn(map)
|
||||
new ShowDataLayer(map, {
|
||||
features: new StaticFeatureSource([wayGeojson]),
|
||||
features: new StaticFeatureSource<Feature<LineString, { id: string }>>([wayGeojson]),
|
||||
drawMarkers: true,
|
||||
layer: layer,
|
||||
})
|
||||
|
@ -80,8 +81,8 @@
|
|||
{
|
||||
id: string
|
||||
index: number
|
||||
dist: number
|
||||
location: number
|
||||
dist?: number
|
||||
location?: number
|
||||
}
|
||||
>[]
|
||||
> = new UIEventSource([])
|
||||
|
@ -97,7 +98,7 @@
|
|||
return
|
||||
}
|
||||
splitPoints.data.splice(i, 1)
|
||||
splitPoints.ping()
|
||||
splitPoints.update(ls => [...ls])
|
||||
},
|
||||
})
|
||||
let id = 0
|
||||
|
@ -105,8 +106,7 @@
|
|||
let projected: Feature<Point, { index: number; id: string; reuse?: string }> = <any>(
|
||||
GeoOperations.nearestPoint(wayGeojson, [lon, lat])
|
||||
)
|
||||
|
||||
console.log("Added splitpoint", projected, id)
|
||||
projected.properties.id = "" + id
|
||||
|
||||
// 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 previousDistance = GeoOperations.distanceBetween(previousPoint, p)
|
||||
|
||||
console.log("ND", nextDistance, "PD", previousDistance)
|
||||
if (nextDistance <= snapTolerance && previousDistance >= nextDistance) {
|
||||
projected = {
|
||||
type: "Feature",
|
||||
|
@ -150,7 +149,7 @@
|
|||
|
||||
id++
|
||||
splitPoints.data.push(projected)
|
||||
splitPoints.ping()
|
||||
splitPoints.update(ls => [...ls])
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue