Giter VIP home page Giter VIP logo

Comments (3)

plainheart avatar plainheart commented on May 31, 2024 2

Released v1.6.0 and published it to npm.

from echarts-extension-gmap.

maeln avatar maeln commented on May 31, 2024

Ok, so I have been able to track down and replicate the issue.
The issue come from how zrender compute the canvas resize.
In Painter.js (in zrender/echart) you can find the function CanvasPainter.resize :

CanvasPainter.prototype.resize = function (width, height) {
        if (!this._domRoot.style) {
            if (width == null || height == null) {
                return;
            }
            this._width = width;
            this._height = height;
            this.getLayer(CANVAS_ZLEVEL).resize(width, height);
        }
        else {
            var domRoot = this._domRoot;
            domRoot.style.display = 'none';
            var opts = this._opts;
            var root = this.root;
            width != null && (opts.width = width);
            height != null && (opts.height = height);
            width = getSize(root, 0, opts);
            height = getSize(root, 1, opts);
            domRoot.style.display = '';
            if (this._width !== width || height !== this._height) {
                domRoot.style.width = width + 'px';
                domRoot.style.height = height + 'px';
                for (var id in this._layers) {
                    if (this._layers.hasOwnProperty(id)) {
                        this._layers[id].resize(width, height);
                    }
                }
                this.refresh(true);
            }
            this._width = width;
            this._height = height;
        }
        return this;
    };

This function call the getSize function, which do the following:

export function getSize(root, whIdx, opts) {
    var wh = ['width', 'height'][whIdx];
    var cwh = ['clientWidth', 'clientHeight'][whIdx];
    var plt = ['paddingLeft', 'paddingTop'][whIdx];
    var prb = ['paddingRight', 'paddingBottom'][whIdx];
    if (opts[wh] != null && opts[wh] !== 'auto') {
        return parseFloat(opts[wh]);
    }
    var stl = document.defaultView.getComputedStyle(root);
    return ((root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh]))
        - (parseInt10(stl[plt]) || 0)
        - (parseInt10(stl[prb]) || 0)) | 0;
}

It looks complex, but it basically more or less just get the width and height of the root div.
This div is the root div which contains the map.
The issue comes from when the container div has a size that is not the fullscreen size. The canvas will match this size no matter what instead of matching the fullscreen size.
For exemple, if you take the default exemple codepen, it works with no issue because the root div has a width and height of 100% and has no parent except the body: https://codepen.io/plainheart/pen/VweLGbR

But if you update the codepen and change the style of the div to a fixed sized, you will be able to reproduce the issue: https://codepen.io/maeln/pen/XWxmPpe
Try to go fullscreen and you should see all the point disappear unless you move the map so that they are in the left top corner.

A potential fix to this would be to pass the first child of the ec-extension-google-map to the resize function instead, since this one has an absolute position (so it doesn't depend on the parent sizing) and correctly resize to fullscreen:
4

from echarts-extension-gmap.

maeln avatar maeln commented on May 31, 2024

Since the PR has been approved, I close this issue. Thanks @plainheart !

from echarts-extension-gmap.

Related Issues (12)

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.