gabesmed / ember-leaflet

Ember + Leaflet = Fun with maps
gabesmed.github.io/ember-leaflet
MIT License
164 stars 35 forks source link

Determining the parent of a clustered marker #128

Open jewe opened 9 years ago

jewe commented 9 years ago

Is it currently possible to determine the parent of a clustered marker? This would be useful to e.g open the cluster for a selected marker.

There is this function - but i don't know how to access the marker object inside MarkerCollectionLayer (contentBinding):

markerClusterGroup.getVisibleParent(marker);
jewe commented 9 years ago

I found a quite hacky solution by myself:

I use a lookup table in the controller to find the marker object by my internal id:

didCreateLayer:function(){
    this._updateLayerOnIconChange();
    this.get('controller').id2leaflet_id[this.content.id] = this._layer; // add to lookup table
},

Now i can open ever clustered marker:

var marker = this.id2leaflet_id[marker.id];
if (marker.__parent) {
    $(marker.__parent._icon).trigger("click");
}