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

pydeck: Use properties values in JSON data to display a tooltip #4858

Closed
ChrisH1993 opened this issue Aug 12, 2020 · 2 comments
Closed

pydeck: Use properties values in JSON data to display a tooltip #4858

ChrisH1993 opened this issue Aug 12, 2020 · 2 comments
Assignees

Comments

@ChrisH1993
Copy link

Hello everyone,

I am new to using the Pydeck module.
At the moment I am trying to make a tooltip work, but could not get it to work after looking through the documentation.
I attached part of my code as an image.
I am trying to pass values from the properties values in the GeoJSON file. However, at the moment it will only display it as plain text instead of being a value.
Would someone be able to help me out?

Kind regards,

Chris

image
image

@ajduberstein
Copy link
Collaborator

ajduberstein commented Aug 15, 2020

Currently not supported in pydeck but it's a reasonable feature request.

As a workaround, you can load the GeoJSON into a Pandas DataFrame and make all these properties top-level. Alternately you could load the data with GeoPandas and it will extract the properties.

import pydeck as pdk
import geopandas as gpd

DATA_URL = 'https://raw.githubusercontent.com/MinnPost/simple-map-d3/master/example-data/world-population.geo.json'

world = gpd.read_file(DATA_URL)
display(world.head())
layers = [
    pdk.Layer(
        "GeoJsonLayer",
        data=world,
        pickable=True,
        auto_highlight=True,
        get_fill_color=[255, 255, 140]),
]

pdk.Deck(
    layers,
    map_provider=None,
    tooltip={'text': '{NAME}, with a population of {POP2005}'},
).to_html("json-example.html", css_background_color="cornflowerblue")

tooltip-q

@ajduberstein ajduberstein changed the title Use properties values in JSON data to display a tooltip pydeck: Use properties values in JSON data to display a tooltip Aug 29, 2020
@ChrisH1993
Copy link
Author

Im sorry for the late answer, I have been occupied with a lot of other things, but thanks to your replay I was able to make it work! Thanks for helping!

Regards,

Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants