You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, it is possible to use GeoJson and add a tooltip based on the GeoJson property. However, as soon as the marker cluster plugin is used, this doesn't work anymore. Means, the tooltips are just not shown.
I spent a lot of time searching in the internet for a solution but I couldn't find anything. Therefore, I debugged the issues by myself. As a hint: I have experience in Python but I'm not at all a JavaScript expert. So, please excuse possible stupid questions.
The problem with current appraoch in folium is the following: A GeoJsonTooltip object is add as child to the GeoJson object and during code generation this leads to JavaScript code where the bindTooltip method of the GeoJson object is used. According to the Leaflet doc this seems to be right but what actually need to be done is, calling the bindTooltip method of the layer for each feature. I tested this on my fork and it works. With the current implementation, you can even see a Javascript error in the debug console of the browser.
To make it work, I changed the template code of theGeoJsonTooltipobject so that the bindTooltip method of its parent (GeoJsonobject) is not directly called but generates a JavaScript function which must be called in the onEachFeature callback in the generated GeoJson JavaScript code. However, this concept does not feel right. It might be a general solution for the GeoJsonTooltip class but will probably not work for the general Tooltip class or at least breaks existing code.
I thought a bit about a general solution. Maybe an extra argument like on_each_feature in the Python add_child method could indicate the child object to change the generated code so that the parent object can bind the tooltip on each feature instead. But I'm not so familiar with the whole project. Maybe there is a much better solution.
The text was updated successfully, but these errors were encountered:
At the moment, it is possible to use
GeoJson
and add a tooltip based on theGeoJson
property. However, as soon as the marker cluster plugin is used, this doesn't work anymore. Means, the tooltips are just not shown.I spent a lot of time searching in the internet for a solution but I couldn't find anything. Therefore, I debugged the issues by myself. As a hint: I have experience in Python but I'm not at all a JavaScript expert. So, please excuse possible stupid questions.
The problem with current appraoch in folium is the following: A
GeoJsonTooltip
object is add as child to theGeoJson
object and during code generation this leads to JavaScript code where thebindTooltip
method of theGeoJson
object is used. According to the Leaflet doc this seems to be right but what actually need to be done is, calling thebindTooltip
method of the layer for each feature. I tested this on my fork and it works. With the current implementation, you can even see a Javascript error in the debug console of the browser.To make it work, I changed the template code of the
GeoJsonTooltip
object so that thebindTooltip
method of its parent (GeoJson
object) is not directly called but generates a JavaScript function which must be called in theonEachFeature
callback in the generatedGeoJson
JavaScript code. However, this concept does not feel right. It might be a general solution for theGeoJsonTooltip
class but will probably not work for the generalTooltip
class or at least breaks existing code.I thought a bit about a general solution. Maybe an extra argument like
on_each_feature
in the Pythonadd_child
method could indicate the child object to change the generated code so that the parent object can bind the tooltip on each feature instead. But I'm not so familiar with the whole project. Maybe there is a much better solution.The text was updated successfully, but these errors were encountered: