@vis.gl/react-google-maps
Advanced tools
Comparing version 0.3.3 to 0.4.0
/// <reference types="google.maps" /> | ||
import { PropsWithChildren } from 'react'; | ||
/** | ||
@@ -9,2 +10,2 @@ * Props for the Pin component | ||
*/ | ||
export declare const Pin: (props: PinProps) => null; | ||
export declare const Pin: (props: PropsWithChildren<PinProps>) => import("react").ReactPortal; |
@@ -1376,2 +1376,5 @@ (function (global, factory) { | ||
var advancedMarker = (_useContext = React.useContext(AdvancedMarkerContext)) == null ? void 0 : _useContext.marker; | ||
var glyphContainer = React.useMemo(function () { | ||
return document.createElement('div'); | ||
}, []); | ||
// Create Pin View instance | ||
@@ -1385,8 +1388,19 @@ React.useEffect(function () { | ||
} | ||
if (props.glyph && props.children) { | ||
logErrorOnce('The <Pin> component only uses children to render the glyph if both the glyph property and children are present.'); | ||
} | ||
if (React.Children.count(props.children) > 1) { | ||
logErrorOnce('Passing multiple children to the <Pin> component might lead to unexpected results.'); | ||
} | ||
var pinViewOptions = _extends({}, props); | ||
var pinElement = new google.maps.marker.PinElement(pinViewOptions); | ||
// Set glyph to glyph container if children are present (rendered via portal). | ||
// If both props.glyph and props.children are present, props.children takes priority. | ||
if (props.children) { | ||
pinElement.glyph = glyphContainer; | ||
} | ||
// Set content of Advanced Marker View to the Pin View element | ||
advancedMarker.content = pinElement.element; | ||
}, [advancedMarker, props]); | ||
return null; | ||
return reactDom.createPortal(props.children, glyphContainer); | ||
}; | ||
@@ -1393,0 +1407,0 @@ |
{ | ||
"name": "@vis.gl/react-google-maps", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "React components and hooks for Google Maps.", | ||
@@ -5,0 +5,0 @@ "source": "src/index.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
416579
5845