Hi!
I’m building a map using d3-geo. I’d like to the map to have three features:
- When the user clicks on a feature in the map, the feature’s fill color changes and properties of that feature are displayed in a
div
above thesvg
containing the map. - When the user clicks on a location in the svg that is not contained by a feature, all of the features assume the same fill color, and properties of any features previously displayed in the
div
above thesvg
disappear. - The map is pan-able and zoom-able (in response to the standard mouse events and gestures).
In this notebook, I’ve got #1 and #2 working (see this cell).
When I add #3 (in this cell), however, things aren’t working the way I want. Zoom and pan behave as I expect, but the response of the map to clicks isn’t what I expect. Sometimes, some of the features respond to clicks as in #1 and #2 while other features don’t. Other times, none of the features respond to clicks. I should also say that responses to clicks are what I expect until I pan and zoom. After any panning or zooming, however, the clicks don’t work anymore.
Presumably this is some sort of event propagation issue?
In case it matters, I’ve copied the code to enable panning and zooming from this cell in the collection of zoom examples.
What am I doing wrong?
Thanks!