Skip to content

Commit

Permalink
docs: update map-3d example for react-19 (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulthink authored Jan 30, 2025
1 parent 4fb2829 commit 1e9ae7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
11 changes: 2 additions & 9 deletions examples/map-3d/src/map-3d/map-3d-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,18 @@ declare module '@vis.gl/react-google-maps' {

// add the <gmp-map-3d> custom-element to the JSX.IntrinsicElements
// interface, so it can be used in jsx
declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
['gmp-map-3d']: CustomElement<
google.maps.maps3d.Map3DElement,
{
[key in GmpMap3DAttributeNames]?: string;
}
google.maps.maps3d.Map3DElement
>;
}
}
}

type GmpMap3DAttributeNames = keyof Omit<
google.maps.maps3d.Map3DElementOptions,
'bounds'
>;

// a helper type for CustomElement definitions
type CustomElement<TElem, TAttr> = Partial<
TAttr &
Expand Down
18 changes: 5 additions & 13 deletions examples/map-3d/src/map-3d/map-3d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,16 @@ export const Map3D = forwardRef(
google.maps.maps3d.Map3DElement | null
>(forwardedRef, () => map3DElement, [map3DElement]);

const centerString = useMemo(() => {
const lat = center?.lat ?? 0.0;
const lng = center?.lng ?? 0.0;
const altitude = center?.altitude ?? 0.0;

return [lat, lng, altitude].join(',');
}, [center?.lat, center?.lng, center?.altitude]);

if (!customElementsReady) return null;

return (
<gmp-map-3d
ref={map3dRef}
center={centerString}
range={String(props.range)}
heading={String(props.heading)}
tilt={String(props.tilt)}
roll={String(props.roll)}></gmp-map-3d>
center={center}
range={props.range}
heading={props.heading}
tilt={props.tilt}
roll={props.roll}></gmp-map-3d>
);
}
);

0 comments on commit 1e9ae7e

Please sign in to comment.