From 435961a299db8d68d66acd3c5e688bca373b45fa Mon Sep 17 00:00:00 2001 From: Ziad Saab Date: Sun, 29 May 2016 05:43:52 -0400 Subject: [PATCH] feat(OverlayView): allow rendered as children of MarkerCluster * Let `OverlayView` be clusterd in `MarkerClusterer` * Thanks to @ziad-saab * Closes #187 --- src/creators/OverlayViewCreator.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/creators/OverlayViewCreator.js b/src/creators/OverlayViewCreator.js index 2fa71cce..290d6bc4 100644 --- a/src/creators/OverlayViewCreator.js +++ b/src/creators/OverlayViewCreator.js @@ -169,6 +169,21 @@ export default class OverlayViewCreator extends Component { } }; + // If we're inside a MarkerClusterer, allow ourselves to be clustered + if (overlayViewProps.anchorHolderRef) { + if (`MarkerClusterer` === overlayViewProps.anchorHolderRef.getAnchorType()) { + overlayView.getDraggable = function getDraggable() { + return !!overlayViewProps.draggable; + }; + + overlayView.getPosition = function getPosition() { + return new google.maps.LatLng(this.position); + }; + + overlayViewProps.anchorHolderRef.getAnchor().addMarker(overlayView); + } + } + return overlayView; }