An interactive map component that allows users to hover over map regions to see zone names and click on zones to view detailed images.
- Hover Interaction: When hovering over a map area, it slightly scales up, shows the zone name, and dims the rest of the map.
- Click Interaction: Clicking on a zone opens a full-screen modal with a gallery of images for that zone.
- Responsive Design: Works well on different screen sizes.
- Keyboard Navigation: Use arrow keys to navigate through images in the modal, and Escape to close it.
-
File Structure:
your-project/ ├── index.html ├── styles.css ├── script.js ├── City Map.svg # Main map SVG file └── map-images/ # Directory for zone images ├── north-west-area-a.jpg ├── north-west-area-a-2.jpg ├── north-west-area-a-3.jpg ├── north-west-area-b.jpg └── ... -
Image Naming Convention:
- Zone images should follow the naming pattern:
[zone-name-in-kebab-case].jpgfor the first image - Additional images should be numbered:
[zone-name-in-kebab-case]-2.jpg,[zone-name-in-kebab-case]-3.jpg, etc. - For example, zone "NorthWestAreaA" becomes:
north-west-area-a.jpg(first image)north-west-area-a-2.jpg(second image)north-west-area-a-3.jpg(third image)
- Zone images should follow the naming pattern:
-
Running Locally:
- Install Live Server for VS Code
- Right-click on
index.htmland select "Open with Live Server" - Or use any other local development server of your choice
To integrate this into Webflow:
- Create a new custom code element in your Webflow project
- Copy the HTML from
index.htmlinto the custom code element - Add the CSS from
styles.cssto your project's CSS - Add the JavaScript from
script.jsto your project's JavaScript - Upload the SVG map and zone images to your Webflow assets
- To add or modify zones, edit the
<map>and<area>tags in the HTML - To change the hover or modal styles, modify the CSS in
styles.css - To adjust image loading or interaction behavior, edit the JavaScript in
script.js
- Modern web browser with JavaScript enabled
- No external dependencies or frameworks required
- Chrome, Firefox, Safari, Edge (latest versions)
- Internet Explorer is not supported