Code Monkey home page Code Monkey logo

Comments (6)

sakitam-fdd avatar sakitam-fdd commented on May 12, 2024

这是一个bug,dom图层添加这块处理的有问题,没有考虑地图容器,本周我会处理一下

from ol3echarts.

a24576946 avatar a24576946 commented on May 12, 2024

请问这个问题解决了吗?项目上很着急

from ol3echarts.

sakitam-fdd avatar sakitam-fdd commented on May 12, 2024

@a24576946 可能需要稍等两天,有兴趣可以处理一下 问题定位 给我发个 pr。

from ol3echarts.

sakitam-fdd avatar sakitam-fdd commented on May 12, 2024

@sunday60004 @a24576946 稍后请升级 v1.3.6再试下 🍶

from ol3echarts.

kyleinfo avatar kyleinfo commented on May 12, 2024

年后换服务器发现几个月前的代码全挂了,看了源代码 v1.3.6 的处理方式是有 bug 的,getTarget 支持 id,className,TagName 和 querySelectorAll 查找 dom,但是 v1.3.6 只考虑了 className,TagName 两种情况,ol 的 getViewport() 返回的是 HTMLElement,HTMLElement 是没有 getElementById 和 querySelectorAll 方法的。
我简单处理了一下,用 getElementById 和 querySelectorAll 时指定为 docment :

const getTarget = (selector, doc = document) => {
  let dom = (function () {
    let found;
    return doc && /^#([\w-]+)$/.test(selector)
      ? (found = document.getElementById(RegExp.$1)) // eslint-disable-line
        ? [found]
        : [] // eslint-disable-line
      : Array.prototype.slice.call(
        /^\.([\w-]+)$/.test(selector)
          ? doc.getElementsByClassName(RegExp.$1)
          : /^[\w-]+$/.test(selector)
            ? doc.getElementsByTagName(selector)
            : document.querySelectorAll(selector)
      );
  })();
  return dom;
};

我之前的处理方式是创建完 map,找到 dom 给它设置 id,getTarget 就会走 getElementById 这条途径,不至于走 getElementsByClassName 导致所有图全在一张图上。

document.getElementById("mid_map").firstChild.children[1].id = "mid_map_id";

from ol3echarts.

sakitam-fdd avatar sakitam-fdd commented on May 12, 2024

@kyleinfo 是的确实会有这个问题,但是现在整体的处理方式还是有点不完美,如果有更好的解决方案可以发个Pull Request。另外一个就是建议锁定一下版本,因为现在的整体测试用例没有完全覆盖,有些时候的大问题的修复对之前版本的兼容考虑的还不够 😢

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.