- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想为 JVectorMap 插件设置单个区域和悬停颜色,并将没有数据的区域保留为默认白色。
到目前为止,我已经删除了比例数据并用颜色代码替换它(如下面的代码所示)。这太棒了,但我不知道如何添加悬停数据。
如果可能的话,我还想添加 document.body.style.cursor 的数据,以便我可以关闭各个区域(例如,该实体被阻止进行交易),以便它似乎不是一个事件链接。
您还会注意到我有代码可以打开其中的面板。它用于显示完整的弹出 div,其中包含我有数据的每个区域的个性化内容。它是继承的代码,所以说实话我不确定它是如何工作的。
如果我忘记了什么,请告诉我。
jQuery.noConflict();
jQuery(function(){
var $ = jQuery;
$('#map_custom').vectorMap({
map: 'world_mill_en',
backgroundColor : "#b8b8b8",
regionStyle : {
initial : {
fill : "white",
"fill-opacity" : 1,
stroke : "none",
"stroke-width" : 0,
"stroke-opacity" : 1
},
hover : {
"fill-opacity": 0.7,
},
selectedHover : {}
},
onRegionOver: function (event, code, region) {
document.body.style.cursor = "pointer";
},
onRegionOut: function (element, code, region) {
document.body.style.cursor = "default";
},
onRegionClick: function(event, code, region){
if (code == "CA") {window.location = 'CalRamic-distributors-Canada.html'}
if (code == "US") {window.location = 'CalRamic-distributors-USA.html'}
if (code == "IE") {
$(".panel").hide("fast");
$("#ireland").show("slow");
document.getElementById('test_data').innerHTML=code;
}
if (code == "GB") {
$(".panel").hide("fast");
$("#unitedkingdom").show("slow");
document.getElementById('test_data').innerHTML=code;
}
if (code == "ES") {
$(".panel").hide("fast");
$("#spain").show("slow");
document.getElementById('test_data').innerHTML=code;
}
if (code == "PT") {
$(".panel").hide("fast");
$("#portugal").show("slow");
document.getElementById('test_data').innerHTML=code;
}
if (code == "IL") {
$(".panel").hide("fast");
$("#israel").show("slow");
document.getElementById('test_data').innerHTML=code;
}
// I've got a LOT more countries in my code, but you don't need all of them
else if (code){
event.preventDefault();
}
},
series: {
regions: [{
values: sample_data
}]
}
});
/* Close the Panel */
$("body").click(function(e) {
if (e.target.id == "close" || $(e.target).parents("#close").size())
{
$(".panel").hide("slow");
}
});
})
目前,此代码从sample_data.js 文件中提取颜色数据,其格式如下:
var sample_data = {
"CA": '#0071a4',
"US": '#0071a4',
"IE": '#0071a4',
"GB": '#0071a4',
"ES": '#0071a4',
}
感谢这里的社区,对于一个新手来说,我已经取得了很大的进步,但我被要求使用 jvectormap 比以前走得更远。可悲的是,我只对这个编程代码有危险,所以我正在联系专家。
最佳答案
首先,这只是一个建议,你应该摆脱疯狂的 if 逻辑,并使其成为一个通用的函数。
例如:
function panelHandler(element, hideSpeed, showSpeed){
$('.panel').hide(hideSpeed);
$(element).show(showSpeed);
$('#test_data').innerHTML('code');
}
if (code == "IE") {
panelHandler("#unitedKingdom", "slow", "fast");
}
if (code == "GB") {
panelHandler("#spain", "slow", "fast");
}
etc...
对于你的问题,只需附上你想要的相应类(class)设置即可。然后,您在事件上检查它,并像这样执行它:
$('#selector').css('cursor', 'pointer');
希望这有帮助。如果您需要更详细的信息,请告诉我,我可以提供帮助。
关于jquery - Jvectormap - 设置每个区域的悬停颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16324670/
我正在更新我们的应用程序以使用 jVectorMap 而不是 Flash。有些 map 需要将国家/地区涂上不同的颜色。创建起来非常简单。 var myData = {
我想请查看我的来源。 我有问题:我需要更改国家/地区颜色,但颜色:...功能对我不起作用。 map 为白色,颜色不变。 请回答。 谢谢! jQuery.noConflict(); jQuery(fu
我正在尝试验证是否可以使用 jvectormap 在 map 上的标记之间绘制线条。 这是我想要实现的目标:http://i.imgur.com/p1Zypv3.gif 有人可以给我一个提示是否可行,
我正在使用 J Vector Map ( http://jvectormap.com/documentation/javascript-api/ ) 创建美国 map 。 我想要做的是为每个州提供一个
我正在使用 jVectorMap 插件将 map 添加到网站。这是我在页面加载时添加标记的 map 。有没有办法动态地做到这一点?我需要通过鼠标单击添加它们。我使用 jVectorMap 插件
与 jVectorMap是否可以隐藏缩放按钮并使用 API 调用放大/缩小?我查过the API documentation并且找不到任何方法,导致 map 重新缩放。 最佳答案 当然。 隐藏按钮:
我正在使用 JVectorMap 显示带有彩色国家/地区的 map 。该 map 还包括一个图例和一个 onRegionTipShow。在我的应用程序中,可以更改 map 所基于的值。执行此操作后,应
所以我想根据我将鼠标放在的国家/地区在我的 Jvectormap 标签上添加图像。我已经设法做到了,但问题是,或者它总是同一张图片,或者我在 map 上的所有其他标签上看到“图像未找到”图标。这是我最
我正在尝试删除笔划并悬停在 jVector map 上的区域 - http://jvectormap.com/ 这是我在js中调用的代码: $(function(){ var markers
jVectorMaps 中是否可以定义可以选择的静态区域? 我只需要定义允许用户选择的 6 个区域。 棘手的部分是,我需要将欧洲、亚洲和世界作为一个地区以及“波兰”和“加拿大”。 如果用户选择波兰,则
当我从外部链接中选择一个区域时,我需要显示一个 HTML 标签。我可以使用以下方法选择区域:map.setSelectedRegions([region]) 但这不显示区域标签。 谁能帮我解决这个问题
我似乎找不到他的插件的任何支持论坛... 我有一个按钮,我想在点击时关注欧洲。 例如,我可以专注于区域,目前我有 $('#map1').vectorMap('set', 'focu
我正在使用 jVectorMap 通过着色显示国家/地区值(即,国家/地区根据其值使用不同的颜色)。一切正常,除非某些国家/地区包含在数据集中。然后这些国家并没有像他们应该的那样被着色(事实上,它们根
我正在使用 http://jvectormap.com/对于在内部使用 webview 的 iOS 应用程序。我的问题是当我在世界地图上触摸一个国家时会出现黑色闪烁。 您甚至可以在 iPad 或 iP
我想为 JVectorMap 插件设置单个区域和悬停颜色,并将没有数据的区域保留为默认白色。 到目前为止,我已经删除了比例数据并用颜色代码替换它(如下面的代码所示)。这太棒了,但我不知道如何添加悬停数
我正在尝试显示我在 map 上突出显示的唯一区域的标签。 这是代码: var map = $('#map').vectorMap({ regionsSelectable: true,
我有Australia的jvectormap 。单击 map 中的特定州时,它应该缩小同一 map 中的该特定州。有没有办法在不使用多 map 的情况下实现这一点。 最佳答案 是的,当然 - 你的意思
我有一张从 SVG 文件转换而来的 map ,现在我想在该 map 上的光标位置添加标记。但标记位置错误,且不遵循任何规则,无法正确监控和修改。 从这个例子:http://jvectormap.com
我有一个使用以下代码创建的 jVectorMap var vmap = $('#world-map').vectorMap({ regionsSelectable: true, reg
我如何设计这样的“world_mill_en” map ? 我知道如何做标记,只需指定经度和纬度即可。我将如何摆脱各大洲之间的所有分界线,并更改填充以使其只是一堆灰点?据我所知,该 api 只允许您将
我是一名优秀的程序员,十分优秀!