Reputation: 236
I have a map of counties in a state.
I am using the code found here http://bl.ocks.org/mbostock/2206590 to implement zooming on my map.
The original example works like this:
This works well enough, the user clicks on a state and it is zoomed and centered using the state centroid. Is it possible to use the mouse location as the point about which to zoom? It would seem easy enough, but I'm not sure how to get the mouse coordinates.
Upvotes: 3
Views: 1994
Reputation: 109272
Use d3.event.x
and d3.event.y
instead of the computed centroid. See here.
Upvotes: 1