Adding jQuery code, mouseover popup infobox

HI to all JS-warriors!

Trying to make this interactive svg map
work inside Hype system.

I pasted the svg code of the map into the inner html and
added the css into the Head of html = works well.

map-us.hype.zip (32.7 KB)

But for the next step - adding jQuery code - here I need a help of js-savvy Hype users!

That jQuery code snippet from the Codepen demo makes it possible to
show/hide the info box that follows / floats over the cursor.
Look up

I am a js novice, so
I simply copy-pasted this jQuery code snippet into the Head Html.
But that obviously didn’t do the trick.
Do I need to tweak this jQuery code or smth else?

The code here places the name of the state within an element with the ID ‘info-box’ so if you add an element to your Hype scene with that Unique Element ID, it will follow your mouse and place the info inside of it when you move your mouse over a state. I added an info-box rectangle outside of the scene area that you can use for this:

map-us.hype.zip (36.1 KB)

1 Like

Hi @Daniel thanks for this great clickable map.

I was trying to modify the “pathcontrol” script so that rather than showing specific data in the info-box, it actually shows / hides another element specific only to that state. Problem is, using the line below to call up a specific state is not working. Any ideas?

selected = path id;

Just looking from the one line you sent, I imagine you may just need a dot instead of space between path and id:

selected = path.id;

If that isn’t it, you may want to attach your current modified version since that line/functionality isn’t in the original so we don’t know where it is going wrong.

@Jonathan - so I tried that and it didn’t work - but this does:
selected = $(this).attr(“id”);

All states show the same colored rectangle except South Carolina which shows a different one
map-us.hype.zip (36.3 KB)

1 Like

Great, glad you got it!