基于Mapael的this minimal example(相关代码的一部分在这里):
$('#refresh').on('click', function() {
// Update some plots and areas attributes ...
var updatedOptions = {'areas' : {}, 'plots' : {}};
// add some new plots ...
var newPlots = {
"Dijon" : {
latitude : 47.323056,
longitude : 5.041944
}
}
$(".mapcontainer").trigger('update', [updatedOptions, newPlots, [], {animDuration : 1000}]);
});
我创建了this example页面,其中包含一个可以正常使用的更新触发器。现在我想把它移到我真正的应用程序php页面,它不起作用!请take a look here。
令人讨厌的部分是浏览器的控制台没有显示任何错误!当我没有看到任何错误时,如何调试此问题?请帮忙!
如果您需要任何其他信息,请询问。感谢您的任何努力。
PS:请忽略脚本和css代码在体内的不良样式。一旦这个问题得到解决,我会解决这个问题。我不认为这是问题,因为有效的示例页面完全相同,并且没有这个问题。
答案 0 :(得分:0)
首先,请注意您使用的是不同版本的Maphael:
其次,在Maphael的“onUpdateEvent”方法(第876行)设置断点之后,似乎事件数据似乎没有传递到处理程序中。
“更新”事件是否与Maphael / Raphael 1.x和2.x具有相同的签名?这是你应该看的地方。
更新:我看了一下2.0.0-dev的内部结构,看来你的更新代码应该是这样的:
var updatedOptions = {'areas': {}, 'plots' : {},
// add some new plots ...
newPlots: {
"Dijon" : {
latitude : 47.323056,
longitude : 5.041944
}
},
animDuration : 1000
};
$(".mapcontainer").trigger('update', updatedOptions);
(最后一行可能是:
$(".mapcontainer").trigger('update', [updatedOptions]);
)
请检查它是否有帮助(虽然我建议您切换到稳定的1.1.0版本的Maphael)。