diff --git a/pyqtlet2/__init__.py b/pyqtlet2/__init__.py index 13df21d..e8614fd 100644 --- a/pyqtlet2/__init__.py +++ b/pyqtlet2/__init__.py @@ -3,7 +3,7 @@ """ __author__ = 'Leon Friedmann ' -__version__ = '0.9.2' +__version__ = '0.9.3' from .mapwidget import MapWidget from .leaflet import L diff --git a/pyqtlet2/leaflet/layer/layer.py b/pyqtlet2/leaflet/layer/layer.py index 9e9f4ea..ad38143 100644 --- a/pyqtlet2/leaflet/layer/layer.py +++ b/pyqtlet2/leaflet/layer/layer.py @@ -36,6 +36,10 @@ def runJavaScriptForMapIndex(self, js): if self._map is not None: self.runJavaScript(js, self._map.mapWidgetIndex) + def getJsResponseForMapIndex(self, js, callback): + if self._map is not None: + self.getJsResponse(js, self._map.mapWidgetIndex, callback) + def __init__(self): super().__init__() self._map = None diff --git a/pyqtlet2/leaflet/layer/layergroup.py b/pyqtlet2/leaflet/layer/layergroup.py index 1e6ef78..6526bda 100644 --- a/pyqtlet2/leaflet/layer/layergroup.py +++ b/pyqtlet2/leaflet/layer/layergroup.py @@ -21,6 +21,8 @@ def _initJs(self): def addLayer(self, layer): self._layers.append(layer) + layer.map = self._map + layer._initJs() js = '{layerGroup}.addLayer({layerName})'.format(layerGroup=self._layerName, layerName=layer._layerName) self.runJavaScriptForMapIndex(js) @@ -39,5 +41,5 @@ def clearLayers(self): self.runJavaScriptForMapIndex(js) def toGeoJSON(self, callback): - self.getJsResponse('{layer}.toGeoJSON()'.format(layer=self.jsName), callback) + self.getJsResponseForMapIndex(f'{self.jsName}.toGeoJSON()', callback) diff --git a/pyqtlet2/leaflet/layer/vector/circle.py b/pyqtlet2/leaflet/layer/vector/circle.py index c0118fa..b52b9bc 100644 --- a/pyqtlet2/leaflet/layer/vector/circle.py +++ b/pyqtlet2/leaflet/layer/vector/circle.py @@ -12,4 +12,4 @@ def _initJs(self): if self.options: leafletJsObject += ', {options}'.format(options=self.options) leafletJsObject += ')' - self._createJsObject(leafletJsObject, self) + self._createJsObject(leafletJsObject, self._map.mapWidgetIndex) diff --git a/setup.py b/setup.py index 80e6444..b311b24 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='pyqtlet2', - version='0.9.2', + version='0.9.3', description='Bringing leaflet maps to Python Qt bindings', long_description=long_description, long_description_content_type="text/markdown",