Question

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:

enter image description here

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.

Was it helpful?

Solution

Use d3.event.x and d3.event.y instead of the computed centroid. See here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top