I am working on a world map with zoom and pan. I draw circles on certain cities and the radius of the circle is determined by the data. When mouse over these circle then a tooltip will show up displaying the data.
The structure of the code is
// Zoom behavior is called on this selection - lets call this parentGroup
// To capture all mouse and touch events
// Call this childGroup
// Tooltip group hidden - will show/hide on mouseover
// Call this toolTipGroup
The problem here is
- If the toolTipGgroup is attached to parentGroup and lives as a sibling to the childGroup then when the map is zoomed the tip position is messed up. I tried getting the (x,y) from the projection and applied a translate(x,y) on the tooltip. The tooltipGroup is translated but its irrelavant since zoom applied.
- If the toolTipGroup is attached to the childGroup, when the map is zoomed the toolTipGroup position is intact but its zoomed along with the childGroup. How to stop the tool tip from scaling along with the map (retain its original size)?
Note: I control the size of the circles by redrawing each of the circles on zoom behavior's callback with the new radius = oldRadius/currentScale