-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add marker event #29
Comments
Have a look at #30 I added 2 events there |
Thanks for be interested. But I still get an "js: Uncaught TypeError: Cannot read property '_onMove' of undefined" error. I think the error is in this function:
|
What do you do before getting this error? |
I don't get the error moving Maker before adding the code you provided. However, when I add the code you provide, I get this error when the move and moveend event are triggered. |
If you try this samlpe code, does the same error occur? import sys
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget
from pyqtlet import L, MapWidget
class MapWindow(QWidget):
def __init__(self):
# Setting up the widgets and layout
super().__init__()
self.mapWidget = MapWidget()
self.layout = QVBoxLayout()
self.layout.addWidget(self.mapWidget)
self.setLayout(self.layout)
# Working with the maps with pyqtlet
self.map = L.map(self.mapWidget)
self.map.setView([12.97, 77.59], 10)
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map)
self.marker = L.marker([12.934056, 77.610029], options={"opacity": 0.5, "draggable": 'true'})
self.marker.bindPopup('Maps are a treasure.')
self.marker.move.connect(self.move) #new listener
self.marker.moveend.connect(self.move_end) #new listener
self.map.addLayer(self.marker)
self.show()
def move(self, event):
print('move', event)
def move_end(self, event):
print('Move end', event["sender"].latLng)
if __name__ == '__main__':
app = QApplication(sys.argv)
widget = MapWindow()
sys.exit(app.exec_()) |
Yes, it worked fine. I guess there is an indirect error in me, I will need to examine it in more detail. Thank you for your attention. |
No worries. You can also send me your code, maybe I see something. I'm looking forward to implement more signals, since got some use for this. |
My project is available on Github: https://github.com/hurturkiha/hurturk-otopilot-arayuzu. I am trying to create a uav ground control station. The codes can be a little confusing to examine. Let me not bother you, I will look in detail and try to find the part that creates the error. |
I found the problem. If we define the marker as manual, it works without any trouble. However, it gives an error when it defines the click event. import sys
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget
from pyqtlet import L, MapWidget
class MapWindow(QWidget):
def __init__(self):
# Setting up the widgets and layout
super().__init__()
self.mapWidget = MapWidget()
self.layout = QVBoxLayout()
self.layout.addWidget(self.mapWidget)
self.setLayout(self.layout)
# Working with the maps with pyqtlet
self.map = L.map(self.mapWidget)
self.map.setView([12.97, 77.59], 10)
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map)
self.map.clicked.connect(self.add_marker)
self.marker = L.marker([12.934056, 77.610029], options={"opacity": 0.5, "draggable": 'true'})
self.marker.move.connect(self.move) #new listener
self.marker.moveend.connect(self.move_end) #new listener
self.map.addLayer(self.marker)
self.show()
def add_marker(self, point):
self.marker = L.marker(point['latlng'], options={"draggable": 'true'})
self.marker.move.connect(self.move) # new listener
self.marker.moveend.connect(self.move_end) # new listener
self.map.addLayer(self.marker)
def move(self, event):
print('move', event)
def move_end(self, event):
print('Move end', event["sender"].latLng)
if __name__ == '__main__':
app = QApplication(sys.argv)
widget = MapWindow()
sys.exit(app.exec_()) |
Currently you are overwriting the |
The same problem occurs when the marker is not object variable. I was thinking there was a problem converting the object from Python to Javascript. However, then there should have been a problem when adding manually. So strange. |
These errors aren't your fault. They're a problem with pyqtlet itself. The second error, the
The first error is caused by the second. Since it begins with In order to access Python objects from the Javascript interpreter, objects must be registered before the client is initialized and the Python attribute must also be defined as a QtCore.Property, with a getter and setter. |
Hi. Your project is very helpful, thank you. I want to define a drag event for markers. I define a signal like you did, but I get an error "js: Uncaught TypeError: Cannot read property '_onDrag' of undefined". What am I doing wrong?
marker.py
The text was updated successfully, but these errors were encountered: