【发布时间】:2014-06-06 09:39:03
【问题描述】:
我已经使用地图坐标创建了图像地图,并且必须突出显示坐标,这工作正常,但我需要的是,更改突出显示颜色取决于条件...在第一个条件下突出显示该区域红色然后在第二个条件下,同一区域将用黑色突出显示。我可以突出显示同一区域,但我不能同时更改该区域的颜色。
我在 Fiddle Here 上的示例代码:Fiddle Demo
我尝试过使用
<script>
$(document).ready(function () //on page load
{
$('area[title*="UPPER"]').each(function ()//get all areas
{
$(this).addClass("victory");
});
$('area[title*="LOWER"]').each(function ()//get all areas
{
$(this).addClass("lose");
});
//initialize highlight
$('.map').maphilight({ strokeWidth: 0, fillColor: "0000FF", fillOpacity: 0.8, singleSelect: true });
////map wrap
$(".victory").click(function () {
//This block is what creates highlighting by trigger the "alwaysOn",
var data = $(this).data('maphilight') || {};
data.alwaysOn = !data.alwaysOn;
$(this).data('maphilight', data).trigger('alwaysOn.maphilight');
//there is also "neverOn" in the docs, but not sure how to get it to work
});
$('.map').maphilight({ strokeWidth: 0, fillColor: "FFFF00", fillOpacity: 0.8});
$(".lose").click(function () {
//This block is what creates highlighting by trigger the "alwaysOn",
var data = $(this).data('maphilight') || {};
data.alwaysOn = !data.alwaysOn;
$(this).data('maphilight', data).trigger('alwaysOn.maphilight');
//there is also "neverOn" in the docs, but not sure how to get it to work
});
});
</script>
但这是用第二个填充色覆盖第一个填充色。任何人都可以帮助我解决这个问题。
【问题讨论】:
-
用相同的坐标覆盖画布...
-
@Mr.Alien 无法获取。你能解释一下吗
-
查看jsfiddle.net/tZKuv/3,我不会浏览插件文档,但我认为他们可以选择这样做
-
实际上我需要的是,必须突出显示而不悬停(即始终突出显示)。这在 asp.net 图像映射中可能吗?
-
是的,我知道了,但我不确定,我是 PHP 开发人员 :)
标签: jquery asp.net map imagemap