Skip to content

Commit

Permalink
fix(map): undefined rendering-type and color-scheme (#515)
Browse files Browse the repository at this point in the history
when color-scheme and/or rendering-type aren't specified, they were still passed as properties with undefined value to the google.maps.Map-constructor.

This is fixed here, along with the test that failed to detect that problem.
  • Loading branch information
usefulthink authored Sep 6, 2024
1 parent 58a6b0c commit c288d15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/__tests__/map.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('creating and updating map instance', () => {

const [actualEl, actualOptions] = createMapSpy.mock.lastCall!;
expect(screen.getByTestId('map')).toContainElement(actualEl);
expect(actualOptions).toMatchObject({
expect(actualOptions).toStrictEqual({
center: {lat: 53.55, lng: 10.05},
zoom: 12,
mapId: 'mymapid'
Expand Down
9 changes: 7 additions & 2 deletions src/components/map/use-map-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ export function useMapInstance(
mapDiv = document.createElement('div');
mapDiv.style.height = '100%';
container.appendChild(mapDiv);

map = new google.maps.Map(mapDiv, {
...mapOptions,
renderingType: renderingType as google.maps.RenderingType,
colorScheme: colorScheme as google.maps.ColorScheme
...(renderingType
? {renderingType: renderingType as google.maps.RenderingType}
: {}),
...(colorScheme
? {colorScheme: colorScheme as google.maps.ColorScheme}
: {})
});
}

Expand Down

0 comments on commit c288d15

Please sign in to comment.