gpt4 book ai didi

jquery - Mapster 填充区域

转载 作者:行者123 更新时间:2023-11-28 16:28:29 25 4
gpt4 key购买 nike

我使用 mapster js 来显示图像中的某些部分。在内部区域我也使用数据键和类。悬停工作完美,但我需要在加载后填充这些部分,而不仅仅是在悬停时使用特定颜色。我尝试了一些例子但没有用。

$('.plan-img').mapster({
stroke: true,
strokeWidth: 2,
configTimeout: 20000,
mapKey: 'data-key',
onClick: function(data){
if (this.href && this.href !== '#') {
window.open(this.href,'_self');
}
},
onConfigured:function() {

$(".floor-plans .mapster_el").parent().hide();

},

areas:[{
key: 'free',
fillColor: 'A7DC96',
strokeColor: 'A7DC96',
},
{
key: 'sold',
fillColor: 'ff7f7f',
strokeColor: 'ff7f7f',

},
{
key: 'reserve',
fillColor: 'ddde97',
strokeColor: 'ddde97',
}
],
fillOpacity: 0.3
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://trnky2.reklama.sexy/js/jquery.imagemapster.min.js"></script>
<div class="floor-plans">

<div class="plan">
<img src="http://trnky2.reklama.sexy/img/floor-1.jpg" usemap="#floor-1" class="plan-img" data-floor="1">
<map id="floor-1" name="floor-1">

<area shape="rect" data-key="sold" class="sold" alt="" title="" coords="580,78,771,274" href="#" target="">
<area shape="rect" data-key="reserve" class="reserve" alt="" title="" coords="308,81,506,273" href="#" target="">

</map>
</div>

最佳答案

var map = $('.plan-img'),

render = new Array();

render["free"] = {
fillColor: 'A7DC96',
strokeColor: 'A7DC96',
};

render["sold"] = {
fillColor: 'ff7f7f',
strokeColor: 'ff7f7f',
};

render["reserve"] = {
fillColor: 'ddde97',
strokeColor: 'ddde97',
};

map.mapster({
onConfigured: function () {

$(this).parent().parent().find("area").each(function(){

var type = $(this).attr("data-key");
$(this).mapster('set',true,render[type]);

})
},
onClick: function (data) {
if (this.href && this.href !== '#') {
window.open(this.href, '_self');
}
}

});

关于jquery - Mapster 填充区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35668289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com