JaWeilBaum / pyqtlet2

pyqtlet2 extends pyqtlet which initially brought Leaflet maps to PyQt5 and PySide6.
Other
37 stars 19 forks source link

Two map widgets cannot work at the same time #44

Closed xukegithub closed 1 year ago

xukegithub commented 1 year ago

hello! I use the following code to create the map ''' self.map = L.map(self.mapWidget) self.map.setView([50.1364092, 8.5991296], zoom) L.tileLayer("https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png").addTo( self.map) ''' But I wanted to create two maps, so I called the above code twice. But the map created by the second is gray and shows nothing. Then I read ”evented.py“ this file。 I found that there was a problem with this " if Evented.mapWidget: return" because Evented.mapWidget is not None,so it return.

Then before "self.map = L.map(self.mapWidget)", add this line "pyqtlet2.leaflet.core.Evented.mapWidget = None" Now both maps show ok. But the first created map can't be right-clicked to add markers

JaWeilBaum commented 1 year ago

Hi there, I just looked into it and it seems like I found a solution! I'll be testing it on the connected branch and release a version 0.9.0 with the feature!