-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/firebase-analytics
- Loading branch information
Showing
17 changed files
with
307 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/components/Map/RealtimeVehicleTag/LineOverlay/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import { CanvasOverlay } from 'react-map-gl' | ||
|
||
interface Props { | ||
points: Array<[number, number]> | ||
color: string | ||
} | ||
|
||
interface RedrawArgs { | ||
width: number | ||
height: number | ||
ctx: CanvasRenderingContext2D | ||
project: (point: [number, number]) => [number, number] | ||
} | ||
|
||
const LineOverlay = ({ points, color }: Props): JSX.Element | null => { | ||
const redraw = ({ width, height, ctx, project }: RedrawArgs): void => { | ||
ctx.clearRect(0, 0, width, height) | ||
ctx.lineWidth = 4 | ||
ctx.strokeStyle = color | ||
ctx.globalAlpha = 0.4 | ||
ctx.beginPath() | ||
points.forEach((point) => { | ||
const pixel = project([point[1], point[0]]) | ||
ctx.lineTo(pixel[0], pixel[1]) | ||
}) | ||
ctx.stroke() | ||
} | ||
|
||
return <CanvasOverlay redraw={redraw} /> | ||
} | ||
|
||
export default LineOverlay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.