mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Compare commits
No commits in common. "0de2cb26b80fe618b2d1489a954ebf0ce4f2bfff" and "b6eeba437052a5b8b936d98d6c2b10a8c7592de3" have entirely different histories.
0de2cb26b8
...
b6eeba4370
1 changed files with 12 additions and 61 deletions
|
|
@ -135,24 +135,20 @@ export class EventHandlers {
|
||||||
* Handle route hover
|
* Handle route hover
|
||||||
*/
|
*/
|
||||||
handleRouteHover(e) {
|
handleRouteHover(e) {
|
||||||
const clickedFeature = e.features[0]
|
const feature = e.features[0]
|
||||||
if (!clickedFeature) return
|
if (!feature) return
|
||||||
|
|
||||||
const routesLayer = this.controller.layerManager.getLayer('routes')
|
const routesLayer = this.controller.layerManager.getLayer('routes')
|
||||||
if (!routesLayer) return
|
if (!routesLayer) return
|
||||||
|
|
||||||
// Get the full feature from source (not the clipped tile version)
|
|
||||||
// Fallback to clipped feature if full feature not found
|
|
||||||
const fullFeature = this._getFullRouteFeature(clickedFeature.properties) || clickedFeature
|
|
||||||
|
|
||||||
// If a route is selected and we're hovering over a different route, show both
|
// If a route is selected and we're hovering over a different route, show both
|
||||||
if (this.selectedRouteFeature) {
|
if (this.selectedRouteFeature) {
|
||||||
// Check if we're hovering over the same route that's selected
|
// Check if we're hovering over the same route that's selected
|
||||||
const isSameRoute = this._areFeaturesSame(this.selectedRouteFeature, fullFeature)
|
const isSameRoute = this._areFeaturesSame(this.selectedRouteFeature, feature)
|
||||||
|
|
||||||
if (!isSameRoute) {
|
if (!isSameRoute) {
|
||||||
// Show both selected and hovered routes
|
// Show both selected and hovered routes
|
||||||
const features = [this.selectedRouteFeature, fullFeature]
|
const features = [this.selectedRouteFeature, feature]
|
||||||
routesLayer.setHoverRoute({
|
routesLayer.setHoverRoute({
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: features
|
features: features
|
||||||
|
|
@ -162,9 +158,9 @@ export class EventHandlers {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No selection, just show hovered route
|
// No selection, just show hovered route
|
||||||
routesLayer.setHoverRoute(fullFeature)
|
routesLayer.setHoverRoute(feature)
|
||||||
// Create markers for hovered route
|
// Create markers for hovered route
|
||||||
this._createRouteMarkers(fullFeature)
|
this._createRouteMarkers(feature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,47 +183,6 @@ export class EventHandlers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get full route feature from source data (not clipped tile version)
|
|
||||||
* MapLibre returns clipped geometries from queryRenderedFeatures()
|
|
||||||
* We need the full geometry from the source for proper highlighting
|
|
||||||
*/
|
|
||||||
_getFullRouteFeature(properties) {
|
|
||||||
const routesLayer = this.controller.layerManager.getLayer('routes')
|
|
||||||
if (!routesLayer) return null
|
|
||||||
|
|
||||||
const source = this.map.getSource(routesLayer.sourceId)
|
|
||||||
if (!source) return null
|
|
||||||
|
|
||||||
// Get the source data (GeoJSON FeatureCollection)
|
|
||||||
// Try multiple ways to access the data
|
|
||||||
let sourceData = null
|
|
||||||
|
|
||||||
// Method 1: Internal _data property (most common)
|
|
||||||
if (source._data) {
|
|
||||||
sourceData = source._data
|
|
||||||
}
|
|
||||||
// Method 2: Serialize and deserialize (fallback)
|
|
||||||
else if (source.serialize) {
|
|
||||||
const serialized = source.serialize()
|
|
||||||
sourceData = serialized.data
|
|
||||||
}
|
|
||||||
// Method 3: Use cached data from layer
|
|
||||||
else if (routesLayer.data) {
|
|
||||||
sourceData = routesLayer.data
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sourceData || !sourceData.features) return null
|
|
||||||
|
|
||||||
// Find the matching feature by properties
|
|
||||||
return sourceData.features.find(feature => {
|
|
||||||
const props = feature.properties
|
|
||||||
return props.startTime === properties.startTime &&
|
|
||||||
props.endTime === properties.endTime &&
|
|
||||||
props.pointCount === properties.pointCount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two features to see if they represent the same route
|
* Compare two features to see if they represent the same route
|
||||||
*/
|
*/
|
||||||
|
|
@ -302,24 +257,20 @@ export class EventHandlers {
|
||||||
* Handle route click
|
* Handle route click
|
||||||
*/
|
*/
|
||||||
handleRouteClick(e) {
|
handleRouteClick(e) {
|
||||||
const clickedFeature = e.features[0]
|
const feature = e.features[0]
|
||||||
const properties = clickedFeature.properties
|
const properties = feature.properties
|
||||||
|
|
||||||
// Get the full feature from source (not the clipped tile version)
|
// Store selected route
|
||||||
// Fallback to clipped feature if full feature not found
|
this.selectedRouteFeature = feature
|
||||||
const fullFeature = this._getFullRouteFeature(properties) || clickedFeature
|
|
||||||
|
|
||||||
// Store selected route (use full feature)
|
|
||||||
this.selectedRouteFeature = fullFeature
|
|
||||||
|
|
||||||
// Update hover layer to show selected route
|
// Update hover layer to show selected route
|
||||||
const routesLayer = this.controller.layerManager.getLayer('routes')
|
const routesLayer = this.controller.layerManager.getLayer('routes')
|
||||||
if (routesLayer) {
|
if (routesLayer) {
|
||||||
routesLayer.setHoverRoute(fullFeature)
|
routesLayer.setHoverRoute(feature)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create markers for selected route
|
// Create markers for selected route
|
||||||
this._createRouteMarkers(fullFeature)
|
this._createRouteMarkers(feature)
|
||||||
|
|
||||||
// Calculate duration
|
// Calculate duration
|
||||||
const durationSeconds = properties.endTime - properties.startTime
|
const durationSeconds = properties.endTime - properties.startTime
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue