Better Programming

Advice for programmers.

Follow publication

Member-only story

Creating an Interactive Map Using SVG and CSS

Making a map with an on-hover highlight

Code & Coins
Better Programming
Published in
5 min readMar 23, 2018

image provided by Bohemia Realty Group

One of the things I really like about my current job is that I’m always pushed to discover new things and develop new features. My new challenge: given an image of a neighborhood map, develop interactive capability where a user can hover over certain parts (neighborhoods) of the map to highlight them.

Before we dive into the code, there are two important considerations:

  1. The file type of the image should be an SVG (I’m actually not sure if this is achievable with other file types unless you incorporate other images. If I’m wrong then please leave a comment!)
  2. Understanding SVG’s (groups, paths, etc.)

SVG’s are Scalable Vector Graphics images written in XML format. Unlike other file types, such as JPEG and PNG, SVG files do not lose any quality when you zoom or resize the page. They are written with XML, are a web-based picture format thst gives them the ability to adapt their configuration with the webpage, so their resolution/quality doesn’t suffer. To put this into perspective, if you view a PNG or JPEG in your text editor, you’ll see the image itself. When you view an SVG on the other hand:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Code & Coins
Code & Coins

Written by Code & Coins

Blogging about software 👨🏻‍💻 and money 💰 https://linktr.ee/mattcroak

Responses (3)

Write a response

How did you identify which path was that neighborhood?

Wow, such a detailed and well explained rundown of how you solved each problem. I’m impressed!

I have an SVG image but I need to make certain sections to be interactive where a popup appears or highlight when I hover over it. I am using Illustrator and Inkscape but do not know how to create paths for how to make certain sections interactive…