shramov / leaflet-plugins

Plugins for Leaflet library
http://psha.org.ru/b/leaflet-plugins.html
MIT License
722 stars 289 forks source link

Yandex map resize works incorrectly #293

Closed dark-gray closed 3 years ago

dark-gray commented 5 years ago

Hi. Yandex map pane changes its size incorrectly since release 3.1.0 (see gif) Size trouble

As i can see, it's because you removed resize_ function call from _update function (it was there in previous versions). At least, i solved this problem by returning resize_ function back.

_update: function () {
    this._resize(); // RETURNED THIS

    var map = this._map;
    var center = map.getCenter();
    this._yandex.setCenter([center.lat, center.lng], map.getZoom());
    var offset = L.point(0,0).subtract(L.DomUtil.getPosition(map.getPane('mapPane')));
    L.DomUtil.setPosition(this._container, offset); // move to visible part of pane
},

_resize: function (force) {
    var size = this._map.getSize(), style = this._container.style;
    if (style.width === size.x + 'px' && style.height === size.y + 'px')
        if (force !== true) return;
    this.setElementSize(this._container, size);
    this._yandex.container.fitToViewport();
},

And after that: Size trouble solved

brunob commented 5 years ago

Thx for the report, ping @johnd0e ;)

johnd0e commented 5 years ago

Hi.

Yandex map pane changes its size incorrectly since release 3.1.0 (see gif)

I see gif, but I cannot reproduce this with standard example yandex.html. Could you provide your code?

At least, i solved this problem by returning _resize function back.

This seems far from optimal..

johnd0e commented 5 years ago

@dark-gray @all

Is there someone who can tell me how to reproduce the issue? I'd like to fix it, in proper way (that code sample above is not good).

belazz commented 3 years ago

I've run into the similair issue, resizing the container and then executing map.invalidateSize(); doesnt update the map/tiles, though objects are getting redrawn:

Screenshot_11

To reproduce the issue:

  1. Change the width of the map container dynamically
  2. Run map.invalidateSize();
  3. Updates the map properly for other providers (like OSM, or using yandex maps direcly through L.tileLayer), but doesnt work for L.yandex()

map.invalidateSize() works as expected on 3.0.3

johnd0e commented 3 years ago

@belazz

Could you provide complete sample using some sandbox (like jsfiddle or similar)? And what if you skip step 2?

belazz commented 3 years ago

@johnd0e Sorry for not providing jsfiddle right away: https://jsfiddle.net/tsdp7j4r/3/ (1500ms timeout for container resize)

Skipping step 2 doesnt affect L.yandex in any way, but it affects others - they are not getting updated. You can try it in the jsfiddle I provided (try commenting out map.invalidateSize() and see the difference)

johnd0e commented 3 years ago

Ok, I see now. Perhaps we need to reintroduce _resize method.

    _resize: function () {
        this._yandex.container.fitToViewport();
    }

I will check this later (or feel free to do it yourself).