mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-21 15:14:53 +02:00
Compare commits
2 commits
master
...
fix-bounda
| Author | SHA1 | Date | |
|---|---|---|---|
| 40d93a113a | |||
| 871662bccf |
2 changed files with 46 additions and 6 deletions
|
|
@ -1288,8 +1288,8 @@ function addBoundaryLayer(map) {
|
||||||
source: BOUNDARY_SOURCE,
|
source: BOUNDARY_SOURCE,
|
||||||
paint: {
|
paint: {
|
||||||
"line-color": accentColor,
|
"line-color": accentColor,
|
||||||
"line-width": 2,
|
"line-width": 2.5,
|
||||||
"line-opacity": 0.7,
|
"line-opacity": 0.8,
|
||||||
"line-dasharray": [3, 2],
|
"line-dasharray": [3, 2],
|
||||||
},
|
},
|
||||||
}, firstSymbolId)
|
}, firstSymbolId)
|
||||||
|
|
@ -1504,8 +1504,8 @@ const MapView = forwardRef(function MapView(_, ref) {
|
||||||
type: "line",
|
type: "line",
|
||||||
source: MEASURE_SOURCE,
|
source: MEASURE_SOURCE,
|
||||||
paint: {
|
paint: {
|
||||||
"line-color": accentColor,
|
"line-color": "#ff0000",
|
||||||
"line-width": 2,
|
"line-width": 8,
|
||||||
"line-dasharray": [8, 4],
|
"line-dasharray": [8, 4],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -2176,6 +2176,34 @@ const MapView = forwardRef(function MapView(_, ref) {
|
||||||
properties: {},
|
properties: {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log("BOUNDARY DEBUG:")
|
||||||
|
console.log(" source exists:", !!map.getSource(BOUNDARY_SOURCE))
|
||||||
|
console.log(" line layer exists:", !!map.getLayer(BOUNDARY_LAYER))
|
||||||
|
console.log(" fill layer exists:", !!map.getLayer(BOUNDARY_FILL_LAYER))
|
||||||
|
console.log(" line-color:", map.getPaintProperty(BOUNDARY_LAYER, "line-color"))
|
||||||
|
console.log(" line-opacity:", map.getPaintProperty(BOUNDARY_LAYER, "line-opacity"))
|
||||||
|
console.log(" line-width:", map.getPaintProperty(BOUNDARY_LAYER, "line-width"))
|
||||||
|
console.log(" fill-color:", map.getPaintProperty(BOUNDARY_FILL_LAYER, "fill-color"))
|
||||||
|
console.log(" visibility:", map.getLayoutProperty(BOUNDARY_LAYER, "visibility"))
|
||||||
|
console.log(" feature count:", source._data?.features?.length || "unknown")
|
||||||
|
console.log(" geometry type:", boundaryGeometry.type)
|
||||||
|
console.log(" coord count:", boundaryGeometry.type === "Polygon" ? boundaryGeometry.coordinates[0]?.length : boundaryGeometry.coordinates?.length)
|
||||||
|
console.log(" first coord:", boundaryGeometry.type === "Polygon" ? boundaryGeometry.coordinates[0]?.[0] : boundaryGeometry.coordinates?.[0]?.[0]?.[0])
|
||||||
|
console.log(" map center:", map.getCenter())
|
||||||
|
console.log(" map zoom:", map.getZoom())
|
||||||
|
|
||||||
|
// Check if layer is actually in style
|
||||||
|
const styleLayers = map.getStyle().layers
|
||||||
|
const boundaryLayerInStyle = styleLayers.find(l => l.id === BOUNDARY_LAYER)
|
||||||
|
console.log(" layer in style.layers:", !!boundaryLayerInStyle)
|
||||||
|
if (boundaryLayerInStyle) {
|
||||||
|
console.log(" layer def:", JSON.stringify(boundaryLayerInStyle))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force repaint
|
||||||
|
map.triggerRepaint()
|
||||||
|
console.log(" triggered repaint")
|
||||||
|
|
||||||
// Zoom to fit boundary
|
// Zoom to fit boundary
|
||||||
try {
|
try {
|
||||||
const coords = boundaryGeometry.type === 'Polygon'
|
const coords = boundaryGeometry.type === 'Polygon'
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,8 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl
|
||||||
if (result?.raw?.osm_type && result?.raw?.osm_id) {
|
if (result?.raw?.osm_type && result?.raw?.osm_id) {
|
||||||
const current = useStore.getState().selectedPlace
|
const current = useStore.getState().selectedPlace
|
||||||
if (current && current.lat === placeLat && current.lon === placeLon) {
|
if (current && current.lat === placeLat && current.lon === placeLon) {
|
||||||
|
// Skip if OSM data already set (e.g., by wikidata path with osm_relation_id)
|
||||||
|
if (current.raw?.osm_type && current.raw?.osm_id) return
|
||||||
// Merge OSM data into raw, preserving existing data
|
// Merge OSM data into raw, preserving existing data
|
||||||
useStore.getState().setSelectedPlace({
|
useStore.getState().setSelectedPlace({
|
||||||
...current,
|
...current,
|
||||||
|
|
@ -393,7 +395,7 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl
|
||||||
}, [osmType, osmId, placeLat, placeLon])
|
}, [osmType, osmId, placeLat, placeLon])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (osmType && osmId) return
|
// Always run wikidata path when wikidataId is present
|
||||||
if (!wikidataId) return
|
if (!wikidataId) return
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
fetchPlaceByWikidata(wikidataId, controller.signal).then((data) => {
|
fetchPlaceByWikidata(wikidataId, controller.signal).then((data) => {
|
||||||
|
|
@ -405,6 +407,16 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl
|
||||||
osm_relation_id: data.osm_relation_id,
|
osm_relation_id: data.osm_relation_id,
|
||||||
extratags: { ...(prev && prev !== "loading" ? prev.extratags : {}), ...data.extratags },
|
extratags: { ...(prev && prev !== "loading" ? prev.extratags : {}), ...data.extratags },
|
||||||
}))
|
}))
|
||||||
|
// Set OSM data from wikidata response so Effect 3 can fetch wiki_summary
|
||||||
|
if (data.osm_relation_id) {
|
||||||
|
const current = useStore.getState().selectedPlace
|
||||||
|
if (current && current.lat === placeLat && current.lon === placeLon) {
|
||||||
|
useStore.getState().setSelectedPlace({
|
||||||
|
...current,
|
||||||
|
raw: { ...current.raw, osm_type: "R", osm_id: data.osm_relation_id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
if (data?.boundary) {
|
if (data?.boundary) {
|
||||||
const current = useStore.getState().selectedPlace
|
const current = useStore.getState().selectedPlace
|
||||||
if (current && current.lat === placeLat && current.lon === placeLon) {
|
if (current && current.lat === placeLat && current.lon === placeLon) {
|
||||||
|
|
@ -417,7 +429,7 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return () => controller.abort()
|
return () => controller.abort()
|
||||||
}, [wikidataId, osmType, osmId, placeLat, placeLon])
|
}, [wikidataId, placeLat, placeLon])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (variant !== "preview" || !userLocation || placeLat == null || placeLon == null) { setDriveTime(null); return }
|
if (variant !== "preview" || !userLocation || placeLat == null || placeLon == null) { setDriveTime(null); return }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue