pbugnion / gmaps

Google maps for Jupyter notebooks
https://jupyter-gmaps.readthedocs.io/en/stable/
Other
760 stars 146 forks source link

Add click handler to GeoJSON features #181

Open nbarjest opened 7 years ago

nbarjest commented 7 years ago

Hi,

I am using your Gmaps package for data visualization in my research. It's a great package. I appreciate you taking the time to prepare it.

In the main page, you have mention the "interactive" feature of the package. Is there a click event that I can use? I want to have a click event so when the user clicks on a polygon, the colors of other polygons changes.

pbugnion commented 7 years ago

Thanks for raising an issue, and for the kind words!

the user clicks on a polygon

What do you mean by polygon here? Do you mean a GeoJSON feature? At the moment, you can't draw your own polygons, apart from through GeoJSON (though I'm working on a feature for this).

Is there a click event that I can use

Assuming the answer to the previous question is that you're defining the polygon through GeoJSON, do you mean that you want to bind a Python function to a click event on a particular GeoJSON feature? If so, that's not available, though it should be fairly straightforward to implement. PRs welcome!

Anyone wanting to implement this should look at how ipywidgets define a click event on buttons (Python-side and JavaScript-side), as well as the documentation for binding click events on features in Google Maps.

nbarjest commented 7 years ago

Yes. By polygon, I mean a GeoJSON feature.

I am talking about a functionality similar to this: https://developers.google.com/maps/documentation/javascript/examples/event-simple In this example, they use "addListener".

pbugnion commented 7 years ago

Thanks for clarifying. As mentioned, click events on GeoJSON features aren't supported yet. Anyone wanting to implement this should look at how ipywidgets define a click event on buttons (Python-side and JavaScript-side), as well as the documentation for binding click events on features in Google Maps.