NewSignature / us-map

An interactive map of the United States using Raphaël
BSD 2-Clause "Simplified" License
280 stars 184 forks source link

Tooltip for when users hover over states #42

Closed eweisbrot closed 10 years ago

eweisbrot commented 10 years ago

Hello,

Is any way to add a tool tip for each state name for when a user hovers over the states? I tried using the code found here to no avail: https://github.com/NewSignature/us-map/issues/31

My map can be found here: http://199.119.123.135/surety-bonds/commercial-bonds/auto_dealer_bond_map.htm

Thanks in advance!

adamfratino commented 10 years ago

Your map doesn't have the ID selectors used in #31. Replace: $('#map-inside, #map-home') with: $('#map')

eweisbrot commented 10 years ago

Thanks for the response. I tried editing the code with your suggestion, but I still can't get it to work. I don't see any errors when I view in developer tools either.

Any ideas as to what the issue is?

adamfratino commented 10 years ago

You could try targeting $('path') instead. If you add a console log message for mouseover do you receive a message in console? For example:

$('path').mousemove(function(e) { var mousex = e.pageX - 30; //Get X coordinates var mousey = e.pageY - 50; //Get Y coordinates console.log(mousex, mousey);

eweisbrot commented 10 years ago

Thanks for the quick response. I tried targeting the $('path'), but still no dice. Bear with me...I'm completely new to javascript.

adamfratino commented 10 years ago

Unfortunately I can't help much because I'm busy, but I've packaged a working example for you to study: (link removed)

eweisbrot commented 10 years ago

Thanks for your time. Hmmm...I copied/pasted your entire script, but the mouseover tool tip still didn't work.

Anyone know what the issue might be?

CaptainStack commented 10 years ago

I have finally got around to making a fork with a few extra features, including the tooltip one that has been requested by @eweisbrot . Check it out:

https://github.com/CaptainStack/us-map

Instructions are in the readme. Please give me feedback and further feature requests!

eweisbrot commented 10 years ago

Hey CaptainStack,

Thanks for making the updates. I'm currently using your updated version of raphael.js and have added "enableToolTips: true" to the map code, but I can't get the tool tips to work. Any ideas why this might be?

Thanks in advance,

eweisbrot commented 10 years ago

Nevermind...got it!

eweisbrot commented 10 years ago

Thanks again!

eweisbrot commented 10 years ago

@CaptainStack

Is there anyway to edit the speed in which the tool tip appears when a user hovers over a state?

CaptainStack commented 10 years ago

@eweisbrot The tooltip is added because the SVG element has a "title" element. Unfortunately, with this implementation, that means that the tooltip will look and behave as specified by the browser's native behavior. Granting more control over the style and behavior of the tooltip would require a more complex solution. It seems enough people might want that I'll consider adding it, but it will take more time.

eweisbrot commented 10 years ago

Alright, no big deal. Works great for now. Thanks again!