Skip to content

Commit

Permalink
grow bbox when too small, for #53
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Jun 3, 2022
1 parent 69ac73e commit 881cc86
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/stores/MapActionReceiver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Action, ActionReceiver } from '@/stores/Dispatcher'
import { Map } from 'ol'
import { fromLonLat } from 'ol/proj'
import {Action, ActionReceiver} from '@/stores/Dispatcher'
import {Map} from 'ol'
import {fromLonLat} from 'ol/proj'
import {
PathDetailsRangeSelected,
RouteRequestSuccess,
Expand All @@ -9,7 +9,7 @@ import {
ZoomMapToPoint,
} from '@/actions/Actions'
import RouteStore from '@/stores/RouteStore'
import { Bbox } from '@/api/graphhopper'
import {Bbox} from '@/api/graphhopper'

export default class MapActionReceiver implements ActionReceiver {
readonly map: Map
Expand Down Expand Up @@ -46,6 +46,14 @@ export default class MapActionReceiver implements ActionReceiver {
widerBBox[2] = Math.max(p[0], widerBBox[2])
widerBBox[3] = Math.max(p[1], widerBBox[3])
});
if (widerBBox[2] - widerBBox[0] < 0.001) {
widerBBox[0] -= 0.0005
widerBBox[2] += 0.0005
}
if (widerBBox[3] - widerBBox[1] < 0.001) {
widerBBox[1] -= 0.0005
widerBBox[3] += 0.0005
}
fitBounds(this.map, widerBBox, isSmallScreen)
} else if (action instanceof SetSelectedPath) {
fitBounds(this.map, action.path.bbox!, isSmallScreen)
Expand Down

0 comments on commit 881cc86

Please sign in to comment.