Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem of using "Yandex.js" with "react-leaflet" plugin #303

Open
azolotova-sc opened this issue Feb 3, 2021 · 2 comments
Open

The problem of using "Yandex.js" with "react-leaflet" plugin #303

azolotova-sc opened this issue Feb 3, 2021 · 2 comments

Comments

@azolotova-sc
Copy link

azolotova-sc commented Feb 3, 2021

Hi, I managed to draw a Yandex map using react-leaflet, but after switching to a different route, an error occurs in the Yandex plugin. During debugging, it turned out that the destroy () event occurs earlier than this._container.remove (), and the other component is not rendered, because container no longer exists

mapa

MapPage.tsx

<MapLeaflet center={ [55.7558, 37.6173]} zoom={13} style={{width: '800px', height: '800px'}}>

<LayersControlReact.BaseLayer name="Yandex Traffic" checked={true}>

</LayersControlReact.BaseLayer>

Yandex.js

_destroy: function (e) {
if (!this._map || this._map === e.target) {
if (this._yandex) {
this._yandex.destroy();
delete this._yandex;
}
delete this._container;
}
},
_setEvents: function (map) {
var events = {
move: this._update
};
if (this._zoomAnimated) {
events.zoomanim = this._animateZoom;
events.zoomend = this._animateZoomEnd;
}
map.on(events, this);
this.once('remove', function () {
map.off(events, this);
this._container.remove(); // we do not call this until api is initialized (ymaps API expects DOM element)
}, this);
},

Ошибка

mistake

@johnd0e
Copy link
Contributor

johnd0e commented Feb 3, 2021

the destroy () event occurs before this._container.remove (),

Is that wrong?

@andreynovikov
Copy link

I've just removed this line. I do not understand its purpose as there is another remove() in the code:
https://github.com/shramov/leaflet-plugins/blob/master/layer/tile/Yandex.js#L161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants