Skip to main content
100%

Untitled

✓ Published0🌍 Public
LLokeshBachu5
Last edited Apr 6, 2023
Created on Apr 6, 2023
Forked from Untitled

This example displays a map of Canada loaded from a GeoJSON file and rendered as SVG paths using D3 v7. When the mouse moves over a province, the code positions an HTML tooltip div through its style attributes. The tooltip reveals the province name, sourced from the GeoJSON properties. The D3 geoPath and geoAlbers APIs handle the map projection and path generation, while province colors change via CSS :hover rules.

AI-generated description

An example showing hovering on a map:

  • Loads d3v7 via UNPKG.
  • Loads map of Canada
  • On mouse move :
    • shows a div by modifying its css properties
    • modifies the content and position of a div (the tooltip)
    • changes the css class of the state to change its color
  • On mouse out :
    • hides the tooltip div
MIT Licensed

Similar vizzes