Skip to content

Commit

Permalink
fix: improve hit detection of routing layer
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Nov 22, 2024
1 parent 12ef93e commit 15dbf29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ol/controls/RoutingControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ class RoutingControl extends Control {
}
return false;
},
hitDetection: this.routingLayer,
pixelTolerance: 6,
source: this.routingLayer?.getSource() || undefined,
});
Expand Down
16 changes: 13 additions & 3 deletions src/ol/styles/routingStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@ const routingStyle: StyleFunction = (
if (minResolution && maxResolution && !inRange) {
return [];
}

const zIndex = feature?.getGeometry()?.getType() === 'Point' ? 100 : 0;

let styles = [blackBorder, redLine];
const mot = feature.get('mot');

if (mot !== 'foot') {
return [blackBorder, redLine];
if (mot === 'foot') {
styles = [dashedRedLine];
}

return [dashedRedLine];
styles = styles.map((style) => {
const tmp = style.clone();
tmp.setZIndex(zIndex);
return tmp;
});

return styles;
};

export default routingStyle;

0 comments on commit 15dbf29

Please sign in to comment.