Coder Social home page Coder Social logo

Comments (6)

sakitam-fdd avatar sakitam-fdd commented on June 3, 2024

@changqingom 这个看起来是新版ol引发的问题,我抽空看下

from ol3echarts.

changqingom avatar changqingom commented on June 3, 2024

@sakitam-fdd 我自己尝试解决,但是卡在了echarts自身事件交互的逻辑这,希望您处理后可以分享下思路 :)

from ol3echarts.

sakitam-fdd avatar sakitam-fdd commented on June 3, 2024

@changqingom 刚刚查了一下,应该是 openlayer的事件处理这边有些变化,事件捕获到 ol-overlaycontainer-stopevent 就终止了。临时解决的话可以暂时继承 Map:

class OMap extends Map {
  handleMapBrowserEvent(mapBrowserEvent) {
    if (!this.frameState_) {
      // With no view defined, we cannot translate pixels into geographical
      // coordinates so interactions cannot be used.
      return;
    }
// 注释掉事件阻止
    // let target = /** @type {Node} */ (mapBrowserEvent.originalEvent.target);
    // while (target) {
    //   if (target.parentElement === this.overlayContainerStopEvent_) {
    //     return;
    //   }
    //   target = target.parentElement;
    // }
    mapBrowserEvent.frameState = this.frameState_;
    const interactionsArray = this.getInteractions().getArray();
    if (this.dispatchEvent(mapBrowserEvent) !== false) {
      for (let i = interactionsArray.length - 1; i >= 0; i--) {
        const interaction = interactionsArray[i];
        if (!interaction.getActive()) {
          continue;
        }
        const cont = interaction.handleEvent(mapBrowserEvent);
        if (!cont) {
          break;
        }
      }
    }
  }
}

并且开启

{
    stopEvent: true,
    insertFirst: true,
}

示例:https://codesandbox.io/s/ol-echarts-example-sfzvh

目前没办法从插件本身处理,如果可能的话可以去mock所有的鼠标事件,可以尝试一下

from ol3echarts.

changqingom avatar changqingom commented on June 3, 2024

@sakitam-fdd ok! 谢谢分享

from ol3echarts.

kyleinfo avatar kyleinfo commented on June 3, 2024

维护项目的时候也遇到了这个问题. 看了下代码. ol-overlaycontainer 现在不在事件分发路径上了. 感觉更改 ol-overlaycontainer-stopevent 的约定不好. 只能 mock 了, zrender 监听的事件, 只有 mousemove 这个事件比较重要, 又没有 mock.

示例: https://codesandbox.io/s/ol-echarts-example-hs7c5

from ol3echarts.

changqingom avatar changqingom commented on June 3, 2024

@kyleinfo 感谢! 那我就写个交互扩展去做这块的派发了

from ol3echarts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.