2

How can I make an area, which was selected - and is therefore rendered with the styles I did defined in render_select - unselected again and make it look like any other areas, that have been never selected before ?

$('img').mapster('set_options',{areas:[{key:'anyAreaKey',selected:false }]});

and

$('img').mapster('set_options',{areas:[{key:'anyAreaKey',highlight:false }]});

dont work for me

Jamie Treworgy
  • 23,934
  • 8
  • 76
  • 119
Kurt
  • 264
  • 1
  • 7
  • 23

1 Answers1

4

To deselect an area, as if the end user had clicked it again, there are several ways:

Deselect by key. changing "false" to "true" below would select instead

$('img').mapster('set',false,'key');

Deselect using the area itself:

$('area[mapkey=key]').mapster('set',false);

Also using the area. There's a complementary "select" method as well. The "deselect" and "select" methods only work on areas.

$('area[mapkey=key]').mapster('deselect');

Example: http://jsfiddle.net/jamietre/MZ9aH/

Docs: http://www.outsharked.com/imagemapster/default.aspx?docs.html#select

The code you're using sets initial options - they won't change the current state state of an area. So while the "selected: false" option would make it initially deselected if the map hadn't been bound yet, it won't do anything after the map has been created. The "highlight: false" option determines whether or not an area will be highlighted on mouseover.

Jamie Treworgy
  • 23,934
  • 8
  • 76
  • 119
  • Thank you very much friendly help!! – Kurt Jul 06 '12 at 16:22
  • @Jamie - Hi Jamie. Is it possible instead to set a property only for the keys that are not currently already selected? I.e. with `image.mapster('get')` I get the areas currently selected and I want to set a certain property for all the other ones. The problem is that you don't have the string of unselected ones so you can't do directly `image.mapster('set', true, 'keys of all unselected')`. Thanks for any help you can give! – Matteo Jan 05 '15 at 17:53