From 4d3c96417228700f45fb2e52df487e51995254da Mon Sep 17 00:00:00 2001 From: Thierry Nicola Date: Thu, 24 Jan 2013 10:52:22 +0100 Subject: [PATCH] #123 adding getVisibleParent for Marker (cherry picked from commit da2952d57bdab7af998ab480200c38212cbc662e) --- src/MarkerClusterGroup.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 8176db4b6..fa30630d3 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -390,6 +390,14 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ this._map = null; }, + getVisibleParent: function(marker){ + var vMarker = marker; + // TODO: Is this safe? No extra check needed to prevent infinite loop? + while(!vMarker._icon) { + vMarker = vMarker.__parent; + } + return vMarker; + }, //Remove the given object from the given array _arraySplice: function (anArray, obj) { @@ -909,4 +917,4 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { L.markerClusterGroup = function (options) { return new L.MarkerClusterGroup(options); -}; \ No newline at end of file +};