-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add rotation to vehicles * Add option to use external icon urls
- Loading branch information
Showing
11 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
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,38 @@ | ||
import 'leaflet-rotatedmarker'; | ||
import { forwardRef, useEffect, useRef } from 'react'; | ||
import { Marker, MarkerProps } from 'react-leaflet'; | ||
export interface RotatedMarkerProps extends MarkerProps { | ||
rotationAngle?: number; | ||
rotationOrigin?: string; | ||
} | ||
export const RotatedMarker = forwardRef<L.Marker, RotatedMarkerProps>( | ||
({ children, rotationAngle, rotationOrigin, ...props }, forwardRef) => { | ||
const markerRef = useRef<L.Marker>(); | ||
|
||
useEffect(() => { | ||
const marker = markerRef.current; | ||
if (marker) { | ||
(marker as any).setRotationAngle(rotationAngle); | ||
(marker as any).setRotationOrigin(rotationOrigin); | ||
} | ||
}, [rotationAngle, rotationOrigin]); | ||
|
||
return ( | ||
<Marker | ||
ref={(ref) => { | ||
if (ref) { | ||
markerRef.current = ref; | ||
// if (forwardRef) { | ||
// forwardRef.current = ref; | ||
// } | ||
} | ||
}} | ||
{...props} | ||
> | ||
{children} | ||
</Marker> | ||
); | ||
} | ||
); | ||
|
||
RotatedMarker.displayName = 'RotatedMarker'; |
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