Skip to content

Commit

Permalink
fix: Add a small safety padding to the map on all the screens
Browse files Browse the repository at this point in the history
This prevents the route to reach the edges of the map
when it is opened
  • Loading branch information
PolariTOON committed Jul 4, 2022
1 parent 5edb53b commit 7a15845
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/Trip/TripMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ const TripMap = () => {
useEffect(() => {
if (geojsonRef.current) {
const geojsonL = geojsonRef.current.leafletElement
mapL.fitBounds(geojsonL.getBounds(), {
paddingBottomRight: [0, mapL.getSize().y * mapPanRatio]
const bounds = geojsonL.getBounds()
const padding = 16
const paddingTopLeft = [padding, padding]
const paddingBottomRight = [
padding,
padding + mapL.getSize().y * mapPanRatio
]
mapL.fitBounds(bounds, {
paddingTopLeft,
paddingBottomRight
})
}
}, [mapL, mapPanRatio])
Expand Down

0 comments on commit 7a15845

Please sign in to comment.