我正在尝试创建一个类似于http://projects.flowingdata.com/walmart/的增长图。jquery,每2秒添加一个元素
我使用https://github.com/marioestrada/jQuery-gMap做马平
什么我目前得到的是一个按钮,当我点击它,我要开始动画。 onclick代码是:
<script>
$("input.buttonB").click(function(){
window.setTimeout(function() {
$('#map_canvas').gMap('addMarker', {
latitude: 41.60252,
longitude: -100.32855,
content: 'Some HTML content'
}
);
}, 2000);
window.setTimeout(function() {
$('#map_canvas').gMap('addMarker', {
latitude: 11.60252,
longitude: -110.32855,
content: 'Some HTML content'
}
);
}, 2000);
});
</script>
问题是,标记不会在屏幕上每2秒出现一次。窗口等待4秒钟,然后同时显示它们两个。
有什么建议吗?
在你的例子中,你不想第二次超出4000毫秒? –
为什么你有两个超时? – Starx
最终会有数百个元素每2秒显示一组。有两个超时,因为我误解了超时。 – Ted