Skip to content

GeoJson Popup #1023

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

Merged
merged 3 commits into from
Jan 5, 2020
Merged

GeoJson Popup #1023

merged 3 commits into from
Jan 5, 2020

Conversation

jtbaker
Copy link
Contributor

@jtbaker jtbaker commented Nov 20, 2018

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.

@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
Copy link
Member

@Conengmo Conengmo left a comment

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.

self.aliases = aliases if aliases is not None else fields
self.labels = labels
self.localize = localize
self.class_name = class_name
Copy link
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
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.

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
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.

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
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?

@ocefpaf ocefpaf force-pushed the master branch 3 times, most recently from 53546b8 to 9f2299a Compare February 26, 2019 19:49
@fullonic
Copy link
Contributor

fullonic commented Nov 3, 2019

@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.
self.style = style
class GeoJsonPopup(GeoJsonDetail):
"""
Create a popup feature to bind to each element of a GeoJson layer based on

Choose a reason for hiding this comment

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

W291 trailing whitespace

@Conengmo
Copy link
Member

Conengmo commented Nov 5, 2019

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

@shape335
Copy link

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

@jtbaker
Copy link
Contributor Author

jtbaker commented Dec 1, 2019

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?

Copy link
Member

@Conengmo Conengmo left a comment

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