I looked at the source code for the plugin you mentioned and it should be fairly easy to extend it so that it will do what you want it to do, here a few hints:
Line 127-136 of jquery.maphighlight.js:
mouseover = function(e) {
var shape = shape_from_area(this);
add_shape_to(canvas, shape[0], shape[1], $.metadata ? $.extend({}, options, $(this).metadata()) : options);
};
if(options.alwaysOn) {
$(map).find('area[coords]').each(mouseover);
} else {
$(map).find('area[coords]').mouseover(mouseover).mouseout(function(e) { clear_canvas(canvas); });
}
This is where all the event magic happens. The mouseover function is used to highlight an area.\
In your code you could try to find the area coordinates you want to highlight by doing something like this:
$(map).find('#id_of_the_area[coords]').each(moseover);
Where id_of_the_area
would be an id that you gave the <area>
tag that you want to highlight.
If you put that into a function you can call that from wherever you need it from.
Edit:
Based on your question in the comment, here are some more pointers:
The functions to highlight/unhighlight an area could look something like this:
function highlight(e) {
$(map).find('#id_of_the_area[coords]').each(moseover);
}
function unHighlight(e) {
clear_canvas($(canvas));
}
In this example id_of_map
and id_of_canvas
would be the id of the map and canvas elements.
The scope of the mouseover
or clear_canvas
functions and map
or canvas
variables might be an issue there. You need to be careful on where to place this code. I'd suggest reading up on jquery plugins a bit before you try to add this functionality.
In jquery you can attach events to any html element. Like this:
$('#id_of_element').mouseover(highlight);
$('#id_of_element').mouseout(unHighlight);
id_of_element would be the id of the element that you would like to trigger the highlighting.
Hope this helps!