简体   繁体   English

如何能够单击地图区域并将颜色更改为红色且透明?

[英]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. 因此,您可以尝试使用。

JSFIDDLE DEMO JSFIDDLE演示

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.

相关问题 如何单击地图区域并在列表上显示数据? - How to be able to click on a map area and display the data on a list? 如何在单击按钮时将 select 边框颜色更改为红色 - how to change select border color to red on button click 如果用户在 canvas 中的透明区域绘制,如何检测透明区域单击或? - How to detect transparent area click OR if user draw in transparent area in canvas? 点击更改地图区域的颜色 - Change colour of map area on click 如何更改点击按钮上的 map 标记颜色 - how to change map marker color on click button 是否有图像映射的替代方法能够更改图像上特定 div 区域的背景颜色? - Is there an alternative to image map to be able to change background-color of a specifif div area on an image? 单击交换按钮时,如何使红色div更改背景颜色以在红色和绿色之间切换? - How do I get my red div to change background color to toggle between red and green when I click on the swap button? 无法更改按钮单击时的文本颜色 - not able to change the color of text on button click 为什么点击后我的链接会短暂变为红色? - Why does my link change color to red briefly after click? 如何在不影响透明区域的情况下在图像上添加颜色? - How to put color on the image without affecting the transparent area?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM