In Pyqtlet, I can link map events to the Pyqt signal-slot structure via the following codes.
map.py:
clicked = pyqtSignal(dict)
@pyqtSlot(QJsonValue)
def _onClick(self, event):
self._logger.debug('map clicked. event: {event}'.format(event=event))
self.clicked.emit(self._qJsonValueToDict(event))
self._connectEventToSignal('click', '_onClick')
evented.py
def _connectEventToSignal(self, event, signalEmitter):
print(self.jsName + "
")
print(event + "
")
print(signalEmitter + "
")
# We need to delete some keys as they are causing circular structures
js = '{name}.on("{event}", function(e) {{
delete e.target;
delete e.sourceTarget;
e = copyWithoutCircularReferences([e], e);
channelObjects.{name}Object.{signalEmitter}(e)}})'.format(
name=self.jsName, event=event, signalEmitter=signalEmitter)
self.runJavaScript(js)
But the same code doesn't work for add marker drag event in maker.py. The error I get is: "js: Uncaught TypeError: Cannot read property '_onDrag' of undefined". I think there is an error in my javascript code. How can I solve it?
question from:
https://stackoverflow.com/questions/65926326/import-leaflet-dragend-event-to-pyqtlet 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…