Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix popup/tooltip issue in the featurelayer #65

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions debug/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
}).addTo(map);

clusterLayer.bindPopup(function (layer) {
console.log(layer)
return layer.feature.properties.stop_desc;
return L.Util.template("<p>{areaname}</p>", layer.feature.properties);
})
</script>

Expand Down
30 changes: 30 additions & 0 deletions src/ClusterFeatureLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});

Expand Down