diff --git a/debug/sample.html b/debug/sample.html index f513f36..d09983f 100644 --- a/debug/sample.html +++ b/debug/sample.html @@ -66,8 +66,7 @@ }).addTo(map); clusterLayer.bindPopup(function (layer) { - console.log(layer) - return layer.feature.properties.stop_desc; + return L.Util.template("
{areaname}
", layer.feature.properties); }) diff --git a/src/ClusterFeatureLayer.js b/src/ClusterFeatureLayer.js index 36fe68f..f1e5a6b 100644 --- a/src/ClusterFeatureLayer.js +++ b/src/ClusterFeatureLayer.js @@ -171,6 +171,36 @@ export var FeatureLayer = FeatureManager.extend({ getFeature: function (id) { return this._layers[id]; + }, + + // This is the same as the Layer.openPopup method except it excludes the `FeatureGroup` + // logic to work around https://github.com/Leaflet/Leaflet/issues/8761 + openPopup (latlng) { + if (this._popup) { + if (this._popup._prepareOpen(latlng || this._latlng)) { + // open the popup on the map + this._popup.openOn(this._map); + } + } + return this; + }, + + // This is the same as the `Layer.openTooltip` method except it excludes the `FeatureGroup` + // logic to work around https://github.com/Leaflet/Leaflet/issues/8761 + openTooltip (latlng) { + if (this._tooltip) { + if (this._tooltip._prepareOpen(latlng)) { + // open the tooltip on the map + this._tooltip.openOn(this._map); + + if (this.getElement) { + this._setAriaDescribedByOnLayer(this); + } else if (this.eachLayer) { + this.eachLayer(this._setAriaDescribedByOnLayer, this); + } + } + } + return this; } });