Skip to content

GeoJson Popup - #1023

Merged
Conengmo merged 3 commits into
python-visualization:masterfrom
jtbaker:GeoJsonPopup
Jan 5, 2020
Merged

Conengmo merged 3 commits into
python-visualization:masterfrom
jtbaker:GeoJsonPopup

Conversation

@jtbaker

@jtbaker jtbaker commented Nov 20, 2018 •

Copy link
Copy Markdown
Contributor

Added GeoJsonPopup class that combines extends functionality of GeoJsonTooltip and VegaLite existing functionality by database-style 'joining' key values from GeoJson to properties in the VegaLite chart data section.

Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
@Conengmo Conengmo added the waiting for review PR is waiting to be reviewed label Feb 9, 2019
@jtbaker jtbaker mentioned this pull request Feb 17, 2019
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved
Comment thread folium/features.py Resolved

@Conengmo Conengmo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool Jason! This is going in the right direction: having a base class that we reuse for the popups and the tooltips.

Overall I don't have much comments, apart from treating the Vega stuff separately and how the class_name things work.

When we agree on the implementation it could use some code styling but that'll come then.

Comment thread folium/features.py
self.aliases = aliases if aliases is not None else fields
self.labels = labels
self.localize = localize
self.class_name = class_name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand how class_name is used. Why not use self.get_name()? I see how it's passed as option to initializing the Leaflet objects, and how it is used as CSS selector in style, but I don't get why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Conengmo - sorry for the extended delay on the modifications to this PR - I think I've addressed most of your concerns with this revision.

re: the class_name: I thought it might be useful for users wanting to add custom css declarations to style the tooltips with a human-readable name. It's also allowed us to take the inline styling out of the html elements and add a top level styling to the class in the head of the document.

Comment thread folium/features.py Resolved
Comment thread folium/features.py Outdated
u""",{{ this.popup_options | tojson | safe }})
{% endmacro %}""")

def __init__(self, fields=None, aliases=None, labels=True, style="margin: auto;", vegalite=None, map_key=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about giving this popup the same options as the 'regular' Popup class? I mean show and sticky options.

Comment thread folium/features.py Outdated
u""",{{ this.popup_options | tojson | safe }})
{% endmacro %}""")

def __init__(self, fields=None, aliases=None, labels=True, style="margin: auto;", vegalite=None, map_key=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default argument for style is a bit confusing. Is it necessary?

Comment thread folium/features.py Resolved
@ocefpaf
ocefpaf force-pushed the master branch 3 times, most recently from 53546b8 to 9f2299a Compare February 26, 2019 19:49
Comment thread folium/features.py Resolved
@fullonic

fullonic commented Nov 3, 2019

Copy link
Copy Markdown
Contributor

@Conengmo , @jtbaker could we merge this feature into master? Or there is still missing something? All test checks are now passed.

In my opinion, having a tooltip as the only way, to add extra information to a marker is a big limitation of folium geojson.

When loading a geojson file from local drive is still possible loop through all points and create a normal marker with a popup, with is ok but doing extra work. However, if the data source is an url, there is no way to generate a popup for each marker. Also tooltips aren't available on mobile devices.

Both GeoJsonPopup and GeoJsonDetail inherit
from this class as they share common attributes.

Also updated the GeoJson JS template to reference this Tooltip object, and added a test to make sure that the values passed exist in the properties.

Merge upstream.
Comment thread folium/features.py Outdated
self.style = style
class GeoJsonPopup(GeoJsonDetail):
"""
Create a popup feature to bind to each element of a GeoJson layer based on

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W291 trailing whitespace

@Conengmo

Conengmo commented Nov 5, 2019

Copy link
Copy Markdown
Member

Nice Jason, I'll look at this PR again.

@shape335

Copy link
Copy Markdown

Thanks for the follow up. I was just unsure what the status was as far as merging. Thank you for clarifying!

@jtbaker

jtbaker commented Dec 1, 2019

Copy link
Copy Markdown
Contributor Author

Thanks for the follow up. I was just unsure what the status was as far as merging. Thank you for clarifying!

NP @shape335. @Conengmo, think you might have a chance to give this another review in the near future?

@Conengmo Conengmo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making changes to this @jtbaker, it looks good! Everything seems to work as expected. The example notebook is also nice. I'll go ahead and merge it.

@Conengmo
Conengmo merged commit f000f2f into python-visualization:master Jan 5, 2020
@Conengmo Conengmo removed the waiting for review PR is waiting to be reviewed label Jan 5, 2020
@jtbaker
jtbaker deleted the GeoJsonPopup branch January 5, 2020 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants