diff --git a/src/components/marker.ts b/src/components/marker.ts index 95e9fcdca..a529e0c49 100644 --- a/src/components/marker.ts +++ b/src/components/marker.ts @@ -90,14 +90,26 @@ function Marker(props: MarkerProps) { const marker: MapboxMarker = useMemo(() => { let hasChildren = false; + let childElement = null; + React.Children.forEach(props.children, el => { if (el) { hasChildren = true; + + const element = el as JSX.Element; + const {children, ...other} = element.props; + + childElement = document.createElement('div'); + + if (other['aria-label']) { + childElement.setAttribute('aria-label', other['aria-label']); + } } }); + const options = { ...props, - element: hasChildren ? document.createElement('div') : null + element: childElement }; const mk = new mapLib.Marker(options).setLngLat([props.longitude, props.latitude]);