简体   繁体   English

使用ImageMapster jQuery无法将图像地图悬停在区域上

[英]Image Map Hover Over Area with ImageMapster jQuery not working

I'm trying to create a hover area for a polygonal image map using the ImageMapster jQuery, but the hover over area isn't working. 我正在尝试使用ImageMapster jQuery为多边形图像地图创建一个悬停区域,但是悬停区域不起作用。 The image map works as it should, but the hovering effect won't work. 图像贴图可以正常工作,但是悬停效果不起作用。 I want each hexagon to change colour when you hover over it with the mouse. 当您将鼠标悬停在六边形上时,我希望每个六边形都可以更改颜色。

Image Map Code: 图片地图代码:

<img id="Image-Maps-Com-image-maps-2014-03-26-105007" src="http://www.image-maps.com/m/private/0/vhiamh2cuht9c2tmik9galgrf7_testbg.jpg" border="0" width="594" height="299" orgWidth="594" orgHeight="299" usemap="#image-maps-2014-03-26-105007" alt="" />
<map name="image-maps-2014-03-26-105007" id="ImageMapsCom-image-maps-2014-03-26-105007">
<area shape="rect" coords="592,297,594,299" alt="Image Map" style="outline:none;" title="Image Map" href="http://www.image-maps.com/index.php?aff=mapped_users_12288" />
<area id="Area One" alt="Area One" title="Area One" href="/areaone/" shape="poly" coords="58,3,167,1,223,96,169,188,59,190,5,95" style="outline:none;" target="_self"     />
<area id="Area Two" alt="Area Two" title="Area Two" href="/areatwo/" shape="poly" coords="230,99,339,99,394,193,340,287,230,288,175,193" style="outline:none;" target="_self"     />
<area id="Area Three" alt="Area Three" title="Area Three" href="/areathree/" shape="poly" coords="403,2,509,2,567,96,511,189,403,190,350,96" style="outline:none;" target="_self"     />
</map>

Map code with ImageMapster jQuery 使用ImageMapster jQuery映射代码

<script type="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.imagemapster.js"></script>

<img id="Image-Maps-Com-image-maps-2014-03-26-105007" src="http://www.image-maps.com/m/private/0/vhiamh2cuht9c2tmik9galgrf7_testbg.jpg" border="0" width="594" height="299" orgWidth="594" orgHeight="299" usemap="#image-maps-2014-03-26-105007" alt="" />
<img src="http://www.image-maps.com/m/private/0/vhiamh2cuht9c2tmik9galgrf7_testcolour.jpg" style="display:none" />
<map name="image-maps-2014-03-26-105007" id="ImageMapsCom-image-maps-2014-03-26-105007">
<area shape="rect" coords="592,297,594,299" alt="Image Map" style="outline:none;" title="Image Map" href="http://www.image-maps.com/index.php?aff=mapped_users_12288" />
<area id="Area One" alt="Area One" title="Area One" href="/areaone/" shape="poly" coords="58,3,167,1,223,96,169,188,59,190,5,95" style="outline:none;" target="_self"     />
<area id="Area Two" alt="Area Two" title="Area Two" href="/areatwo/" shape="poly" coords="230,99,339,99,394,193,340,287,230,288,175,193" style="outline:none;" target="_self"     />
<area id="Area Three" alt="Area Three" title="Area Three" href="/areathree/" shape="poly" coords="403,2,509,2,567,96,511,189,403,190,350,96" style="outline:none;" target="_self"     />
</map>

<script>
$(document).ready(function ()
{
    $('#sanitisationmap').mapster({
    singleSelect : true,
    clickNavigate : true,
    fill : true, altImage : 'http://www.image-maps.com/m/private/0/vhiamh2cuht9c2tmik9galgrf7_testcolour.jpg',
    fillOpacity : 1,
});
});
</script>

I'm sure it's something simple I'm missing. 我确定这是我所缺少的简单事物。 Here's the jfiddle . 这是小提琴

I've also tried to see could I use CSS for this issue, but I've read on here that CSS doesn't really work properly with Image Maps. 我也尝试过查看是否可以使用CSS来解决此问题,但是我在这里已经读到CSS不能与Image Maps一起正常使用。 I've checked off some of the examples on the ImageMapster page and the Beginners site for it, but the hover over isn't working for me. 我已经在ImageMapster页面和Beginners网站上检查了一些示例,但是将鼠标悬停对我而言不起作用。

There appears to be some disconnect between the name of the image you're calling mapster on and the name of your actual image. 您正在调用mapster的图像名称与实际图像名称之间似乎有些脱节。

If you have only the one image on the page or would like the same script to execute on all images on the page, you can use: 如果页面上只有一个图像,或者希望对页面上的所有图像执行相同的脚本,则可以使用:

$('img').mapster({ ... 

Otherwise, make sure you're using the same image name in your script as your HTML 否则,请确保您在脚本中使用与HTML相同的图像名称

As far as your jfiddle goes, link the jquery.imagemapster.js as an external resource and place your script block in the javascript panel. 就您的jfiddle而言,请将jquery.imagemapster.js链接为外部资源,然后将脚本块放置在javascript面板中。 You can also omit the fist 2 script lines as these are not necessary. 您也可以省略第2条脚本行,因为这些行不是必需的。

I forked it here and got it working by doing the above 在这里分叉并通过上述操作使其工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM