Jquery maphilight : want to add simple new features
I'm a beginner with Jquery so those questions should be pretty easy to answer. I'd like to modify the map hilight script (http://plugins.jquery.com/project/maphilight) to add 2 features :
- Question 1. I'd like to be able to highlight some areas by keeping the mouse button pressed instead of having to click and release the button.
Here is the relevant part of the code :
$.fn.maphilight = function(opts) { opts = $.extend({}, $.fn.maphilight.defaults, opts);
return this.each(function() { mouseclick = function(e,id) { ...}// MY CHANGES
mouseover = function(e, id)
{
if(pressed)
mouseclick(e,id)
}
I tried开发者_运维问答 to call the mouseclick function in mouseover but it doesn't highlight anything. I'm probably not calling the function in the right way ?
- Question 2. I'd like to be able to change the color used to highlight areas after pressing a button.
Thanks
I had the same problem.
I ended up extending the plugin to allow for clicks. You can get that code here:
https://github.com/thekevinscott/maphilight
All you need to do is pass in an additional argument in the options, 'stayClicked', as true. Subsequently, any clicks on the map will leave those areas highlighted.
As for your point #2... not sure about that. You'll probably have to modify the plugin a bit yourself.
精彩评论