Repository navigation
Conversation
| private static getEmptyPath(): Path { | ||
| return { | ||
| bbox: [0, 0, 0, 0], | ||
| bbox: undefined, |
There was a problem hiding this comment.
We had a similar discussion before and I am still open to this :) In BasePath the bbox is declared optional, but here we set it to [0, 0, 0, 0] for the empty path. We then check for route.selectedPath.bbox here:
Line 53 in 3d327b0
route.selectedPath.bbox.every(num => num !== 0), but since bbox is declared optional we even need route.selectedPath.bbox && route.selectedPath.bbox.every(num => num !== 0). So we could do this but then I think bbox should not be optional in BasePath. Then again if bbox might be missing I think declaring it optional and handling the cases where it is missing is perfectly fine.
There was a problem hiding this comment.
Yes, I agree. Since [0,0,0,0] is still a valid bbox having it undefined to indicate we really don't have a bbox is probably better.
| } | ||
|
|
||
| fitBounds(bbox: Bbox) { | ||
| if (bbox.every(num => num !== 0)) { |
There was a problem hiding this comment.
Here we do not need the bbox.every check, because if there was no bounding box it would be undefined and since the type here is Bbox (not optional) we do not have to do this check and can rely on the fact it is not missing and we checked for the missing value elsewhere.
There was a problem hiding this comment.
Yes, as stated in the other comment
| private static getEmptyPath(): Path { | ||
| return { | ||
| bbox: [0, 0, 0, 0], | ||
| bbox: undefined, |
There was a problem hiding this comment.
Yes, I agree. Since [0,0,0,0] is still a valid bbox having it undefined to indicate we really don't have a bbox is probably better.
| } | ||
|
|
||
| fitBounds(bbox: Bbox) { | ||
| if (bbox.every(num => num !== 0)) { |
There was a problem hiding this comment.
Yes, as stated in the other comment
|
Thanks for taking a look 👍 |
When the map loads and the bounding box is not the entire world (e.g. when using a local GH server with a smaller server) the map should be focused to the bounding box of the available road network. However, without this fix the initial bounding box we get from /info is ignored.