[英]How to be able to click a map area and change color to red and be transparent?
I'm trying to make a body map which would when clicked on certain parts of the body, be highlighted with the color red and also transparent while staying in that state so I can click on the others too like a selection but so far I can't seem to find the solution. 我正在尝试制作一个人体贴图,当单击人体的某些部位时,将保持红色并以红色突出显示,同时保持该状态不变,以便可以像选择一样单击其他人体,但到目前为止似乎找不到解决方案。
Here is the sample 这是样本
http://79.170.44.80/sicuandomain.com/# http://79.170.44.80/sicuandomain.com/#
Thanks! 谢谢!
I am not myself familiar with the map and area implementation. 我自己并不熟悉地图和区域的实现。 But, After just trying some jQuery Plugins for exercise and learning, I think this will help your cause. 但是,在尝试了一些用于练习和学习的jQuery插件之后,我认为这将对您的事业有所帮助。
jQuery Plugin : http://davidlynch.org/projects/maphilight/docs/ jQuery插件: http : //davidlynch.org/projects/maphilight/docs/
So, Basically you need to initalize the map with this jQuery plugin and define the click event for the area you want to use as : 因此,基本上,您需要使用此jQuery插件来初始化地图,并为要用作的区域定义click事件:
$(function () {
//Initalize the Image with the plugin
$('.map').maphilight({
stroke: false,
//Use the color you want
fillColor: '000000'
});
//Map area selector to intercept the click event
$('#Map area').click(function (e) {
e.preventDefault();
var data = $(this).mouseout().data('maphilight') || {};
data.alwaysOn = !data.alwaysOn;
$(this).data('maphilight', data).trigger('alwaysOn.maphilight');
});
});
The document for the plugin is not good however. 但是,该插件的文档不好。 So, you can try and use if you like. 因此,您可以尝试使用。
There is lot to do here like removing the previous selected area on click event. 这里要做很多事情,例如在单击事件中删除上一个选定的区域。 But, I guess you can achieve that yourself. 但是,我想您可以自己实现。
And, There are other plugins to do the job as well. 并且,还有其他插件也可以完成这项工作。 Plus you should know how the plugins works as well if you would like to do it manually. 另外,如果您想手动进行操作,则应该了解插件的工作原理。
I hope this help your cause. 希望对您的事业有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.