Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions src/google_map_markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,47 @@ export default class GoogleMapMarkers extends Component {
...latLng,
};

if (child.props.markerPosition) {
const markerPosition = child.props.markerPosition;
if (typeof markerPosition === 'string') {
const [left, top] = markerPosition.split(' ');
if (left && top) {
this.markerPosition = { transform: `translate(${left},${top})` };
} else {
console.warn(
`markerPosition expects a two values separated by a single whitespace`
);
}
} else {
console.error(
`markerPosition expects a value of type string, got ${typeof markerPosition} instead.`
);
}
}

return (
<div
key={childKey}
style={{ ...style, ...stylePtPos }}
className={child.props.$markerHolderClassName}
>
{React.cloneElement(child, {
$hover: childKey === this.state.hoverKey,
$getDimensions: this._getDimensions,
$dimensionKey: childKey,
$geoService: this.props.geoService,
$onMouseAllow: this._onMouseAllow,
$prerender: this.props.prerender,
})}
<div
style={{
...style,
...this.markerPosition,
width: undefined,
height: undefined,
}}
>
{React.cloneElement(child, {
$hover: childKey === this.state.hoverKey,
$getDimensions: this._getDimensions,
$dimensionKey: childKey,
$geoService: this.props.geoService,
$onMouseAllow: this._onMouseAllow,
$prerender: this.props.prerender,
})}
</div>
</div>
);
}
Expand Down