该例子里,拖动成都那个点,鼠标放开之后,移动鼠标,地图会一直跟着动...
代码里,在散点上按下鼠标后,会禁用地图缩放移动,然后移动鼠标是为了移动点.
当放开鼠标后,地图恢复可移动状态.
但是实际上,鼠标放开事件并没有正确的作用到地图的roam上,导致鼠标没有按下,但地图会一直跟着动
配置项如下
var uploadedDataURL = "/asset/get/s/data-1517645039291-B1vgpymUz.json";
$.getJSON(uploadedDataURL, function(geoJson) {
echarts.registerMap('zhongguo', geoJson);
myChart.hideLoading();
option = {
title: {
text: '在地图上点击添加散点',
x: 'center',
textStyle: {
color: '#ccc'
}
},
// toolbox: {
// show: true,
// orient: 'vertical',
// left: 'right',
// top: 'center',
// feature: {
// dataView: {readOnly: false},
// restore: {},
// saveAsImage: {}
// }
// },
geo: {
show: true,
map: 'zhongguo',
label: {
emphasis: {
show: true,
}
},
roam: true
},
series: [
{
name: '点',
type: 'scatter',
coordinateSystem: 'geo',
// symbol: 'pin',
label: {
normal: {
formatter: "{b}",
show: true
}
},
zlevel: 6,
data: [{name: "成都", value:[104.06,30.67,100]}],
}
]
};
myChart.setOption(option);
var move = function()
{
};
var up = function()
{
myChart.off("mousemove", move);
myChart.off("mouseup", up);
myChart.setOption
({
geo:
{
roam: true
}
});
}
myChart.on("mousedown", function(event)
{
if (event.componentSubType === "scatter")
{
myChart.setOption
({
geo:
{
roam: false
}
});
myChart.on("mousemove", move);
myChart.on("mouseup", up);
}
});
});