NewSignature / us-map

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

Event examples not working? #1

Open brianrc opened 11 years ago

brianrc commented 11 years ago

Hello, I'm having trouble getting events to work at all. Is below supposed to be replaced with something? It's not clear from the directions. Leaving it in gives a syntax error.

As an option:

$('#map').usmap({

State: { 'MD' : function(event, data) { console.log('You interacted with the state of Maryland'); } } }); Binding it: $('#map').on('usmapMD', function(event, data) { console.log('You clicked on the state of Maryland'); }); I'm trying to display a unique message per state (beyond just the state name) when the user clicks a state. Any help would be much appreciated. Thank you. And thanks for sharing this code! Brian
mattm458 commented 11 years ago

Your option and binding code isn't working correctly because you aren't specifying an event. There's mouseover, mouseout, and click.

This should fix your option code:

$('#map').usmap({
    clickState: {
        'MD': function(event, data) {
            console.log('You interacted with the state of Maryland');
        }
    }
});

As far as I can tell, your binding code should look like the code below. I tried working it into some of my existing map code and it didn't work, so watch out I guess.

$('#map').on('usmapclickMD', function(event, data) {
    console.log('You clicked on the state of Maryland');
});
brianrc commented 11 years ago

Sorry, even inputting both code examples above into the demo file I still cannot get it to work.

One thing to note is the example file includes jquery 1.6.2 and .on() (in example 2) isn't supported until jquery 1.7. However, even updating to jquery 1.8.2, the code still does not work! :(

Yes, I know how to access the console and I even tried replacing it with $('#somediv').html('text here'); but there is no affect when MD is clicked. Tested in latest Chrome and Firefox.

Can you send me a gist that works?

Thanks for your help.

brianrc commented 11 years ago

Are there any other example implementations of this map out there on the web?

I really need to get this working. I'm on a deadline.

Thanks!!

brianrc commented 11 years ago

I found another map that I think is going to be a better fit for me, so this is no longer critical, but thank you all!

SurDoc commented 11 years ago

What map did you find? I cannot get this to work either.

brianrc commented 11 years ago

http://jqvmap.com/ works

SurDoc commented 11 years ago

Hi,

Thank you for the link. I've been trying to add in some code but I am getting errors. I want to add the onClick function but it is not letting me. Any suggestions?

SurDoc commented 11 years ago

Never mind, I got it to function correctly. Thank you all for the help!