You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far this Lib is excellent but i have hit a snag and cant seam to get around it. I want to add a point to the map by clicking a button in QT. This part works fine. But the popup never pops up for the added marker. The marker that was run during init works as expected but the added marker does not. Additionally I added a callback for the click and that works fine for the initial marker but not the added marker. Any suggestions?
`
import sys
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget, QPushButton
from pyqtlet2 import L, MapWidget
class MapWindow(QWidget):
marker2 = L.marker
def __init__(self):
# Setting up the widgets and layout
super().__init__()
self.mapWidget = MapWidget()
self.layout = QVBoxLayout()
self.layout.addWidget(self.mapWidget)
self.button = QPushButton("Push Me")
self.layout.addWidget(self.button)
self.setLayout(self.layout)
self.button.clicked.connect(self.add_point)
# 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])
self.marker.bindPopup('Maps are a treasure.')
self.map.addLayer(self.marker)
self.marker.click.connect(self.click_marker)
self.drawControl = L.control.draw()
self.map.addControl(self.drawControl)
self.show()
def add_point(self):
self.marker2 = L.marker([12.934056, 77.650029]).addTo(self.map).bindPopup("Hi there")
self.marker2.click.connect(self.click_marker)
print("added point")
def click_marker(self, event):
print("click", event)
if name == 'main':
app = QApplication(sys.argv)
widget = MapWindow()
sys.exit(app.exec_())
`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So far this Lib is excellent but i have hit a snag and cant seam to get around it. I want to add a point to the map by clicking a button in QT. This part works fine. But the popup never pops up for the added marker. The marker that was run during init works as expected but the added marker does not. Additionally I added a callback for the click and that works fine for the initial marker but not the added marker. Any suggestions?
`
import sys
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget, QPushButton
from pyqtlet2 import L, MapWidget
class MapWindow(QWidget):
marker2 = L.marker
if name == 'main':
app = QApplication(sys.argv)
widget = MapWindow()
sys.exit(app.exec_())
`
Beta Was this translation helpful? Give feedback.
All reactions