0

I am wanting to use this product to display the US map with states selected already. I do not need any click functionality. I cannot for the life of me prevent the onRegionClick function from firing. I have tried using the ' event.preventDefault ' method, but it doesn't work. Can anybody help?

Thanks, Brad

Huangism
  • 16,278
  • 7
  • 48
  • 74

3 Answers3

0

I tried this:

jQuery('#vmap').vectorMap({ 
  map: 'russia_en',
  // removed other declarations not needed in this example
  onRegionOver: function(event,code, region)
  {
    if (code)
    {
        event.preventDefault();
    }
  }
  });

This prevents the mouseover event to do it's work on the map I loaded. If you add similar code for the other events you should be good.

Lexib0y
  • 519
  • 10
  • 27
  • This looks promising, I will try it tomorrow – 321zeno Dec 03 '14 at 18:20
  • It works for the event I mentioned, if it doesn't for others I can try some more fiddling :) – Lexib0y Dec 03 '14 at 18:30
  • Oh, for some reason `onRegionClick` did not behave like the other events in my implementation, that's why I had to find a workaround eventually. `event.preventDefault();` wasn't doing anything – 321zeno Dec 03 '14 at 18:33
  • it depends where you put it of course, it can be very picky :) – Lexib0y Dec 03 '14 at 18:35
0

I ran into the same issue recently and I ended up using a workaround.

In onRegionClick: function(event, code, region) {...} you could check if code is in the selected states array and use $vmap.vectorMap('set', 'colors', '#selectedOrDeselected') to set the state colors accordingly

321zeno
  • 1,264
  • 1
  • 12
  • 24
0

I also struggled to disable the click on regions, finally I used a simpler solution to disable the clicking on the map :

$('#vmap').off('click');

Kernael
  • 3,270
  • 4
  • 22
  • 42