【解决办法】产品中没有对应的API来判断或者图形是在哪个窗口绘制的。绕行方案:判断鼠标位置位于哪个分屏范围中。var mouseViewportIndex = 0;
viewer.canvas.addEventListener('mousemove', function (e) {
if (scene.multiViewportMode == Cesium.MultiViewportMode.NONE) {
mouseViewportIndex = 0;
} else if (scene.multiViewportMode == Cesium.MultiViewportMode.HORIZONTAL) {
// 判断鼠标在垂直中线的左边还是右边
if (e.clientX > viewer.canvas.width / 2) {
mouseViewportIndex = 1
}
else {
mouseViewportIndex = 0
}
} else if (scene.multiViewportMode == Cesium.MultiViewportMode.VERTICAL) {
// 判断鼠标在水平中线的左边还是右边
if (e.clientY > viewer.canvas.height / 2) {
mouseViewportIndex = 1
}
else {
mouseViewportIndex = 0
}
}
// 更多视口 模式查看:
http://support.supermap.com.cn:8090/webgl/Cesium/docs/Documentation/MultiViewportMode.html
console.log(mouseViewportIndex);
})
【解决办法】对地图的canvas挂载鼠标移动viewer.canvas.addEventListener('mousemove', function (e) {