Skip to content

Commit

Permalink
Adjust structure to work with multiple maps (#54)
Browse files Browse the repository at this point in the history
* Fix the creation of layers using draw control
* Fix LayerGroup.toGeoJSON

---------

Co-authored-by: Baljak <[email protected]>
  • Loading branch information
JaWeilBaum and Baljak authored Feb 2, 2023
1 parent 90d58dc commit 0e9fdd8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyqtlet2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

__author__ = 'Leon Friedmann <[email protected]>'
__version__ = '0.9.2'
__version__ = '0.9.3'

from .mapwidget import MapWidget
from .leaflet import L
4 changes: 4 additions & 0 deletions pyqtlet2/leaflet/layer/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pyqtlet2/leaflet/layer/layergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

2 changes: 1 addition & 1 deletion pyqtlet2/leaflet/layer/vector/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0e9fdd8

Please sign in to comment.