Skip to content

Commit

Permalink
fix: update ControlPosition values (visgl#71)
Browse files Browse the repository at this point in the history
The ControlPosition values used in `@types/google.maps` don't match the values used in the Maps JavaScript API. This updates our internal copy to the latter values.

---------

Co-authored-by: Martin Schuhfuss <m.schuhfuss@gmail.com>
  • Loading branch information
MauricioRobayo and usefulthink authored Nov 9, 2023
1 parent 13c224f commit 1dd144a
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions src/components/map-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,39 @@ type MapControlProps = PropsWithChildren<{
* Copy of the `google.maps.ControlPosition` constants.
* They have to be duplicated here since we can't wait for the maps API to load to be able to use them.
*/
export enum ControlPosition {
BLOCK_END_INLINE_CENTER = 0,
BLOCK_END_INLINE_END = 1,
BLOCK_END_INLINE_START = 2,
BLOCK_START_INLINE_CENTER = 3,
BLOCK_START_INLINE_END = 4,
BLOCK_START_INLINE_START = 5,
BOTTOM_CENTER = 6,
BOTTOM_LEFT = 7,
BOTTOM_RIGHT = 8,
INLINE_END_BLOCK_CENTER = 9,
INLINE_END_BLOCK_END = 10,
INLINE_END_BLOCK_START = 11,
INLINE_START_BLOCK_CENTER = 12,
INLINE_START_BLOCK_END = 13,
INLINE_START_BLOCK_START = 14,
LEFT_BOTTOM = 15,
LEFT_CENTER = 16,
LEFT_TOP = 17,
RIGHT_BOTTOM = 18,
RIGHT_CENTER = 19,
RIGHT_TOP = 20,
TOP_CENTER = 21,
TOP_LEFT = 22,
TOP_RIGHT = 23
}
export const ControlPosition = {
TOP_LEFT: 1,
TOP_CENTER: 2,
TOP: 2,
TOP_RIGHT: 3,
LEFT_CENTER: 4,
LEFT_TOP: 5,
LEFT: 5,
LEFT_BOTTOM: 6,
RIGHT_TOP: 7,
RIGHT: 7,
RIGHT_CENTER: 8,
RIGHT_BOTTOM: 9,
BOTTOM_LEFT: 10,
BOTTOM_CENTER: 11,
BOTTOM: 11,
BOTTOM_RIGHT: 12,
CENTER: 13,
BLOCK_START_INLINE_START: 14,
BLOCK_START_INLINE_CENTER: 15,
BLOCK_START_INLINE_END: 16,
INLINE_START_BLOCK_CENTER: 17,
INLINE_START_BLOCK_START: 18,
INLINE_START_BLOCK_END: 19,
INLINE_END_BLOCK_START: 20,
INLINE_END_BLOCK_CENTER: 21,
INLINE_END_BLOCK_END: 22,
BLOCK_END_INLINE_START: 23,
BLOCK_END_INLINE_CENTER: 24,
BLOCK_END_INLINE_END: 25
} as const;
export type ControlPosition =
(typeof ControlPosition)[keyof typeof ControlPosition];

export const MapControl = ({children, position}: MapControlProps) => {
const controlContainer = useMemo(() => document.createElement('div'), []);
Expand Down

0 comments on commit 1dd144a

Please sign in to comment.