def _init_map(self): self.map = L.map(self.mapWidget) self.map.setView([0, 0], 1) L.tileLayer('http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png', { 'noWrap': 'true' }).addTo(self.map) # Create empty layer group to hold the data self.layerGroup = L.layerGroup() self.map.addLayer(self.layerGroup)
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([47.7982, 13.0528], 6) L.tileLayer('http://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png').addTo( self.map) self.markers = list()
def __init__(self, parent=None): # Setting up the widgets and layout super().__init__(parent=parent) self.mapWidget = MapWidget() self.layout = QVBoxLayout() self.layout.addWidget(self.mapWidget) self.setLayout(self.layout) self.setModal(True) # Working with the maps with pyqtlet self.map = L.map(self.mapWidget) self.map.setView([35.76898, 51.45872], 18) L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map) self.marker = L.circleMarker([35.76898, 51.45872]) self.marker.bindPopup('Maps are a treasure.') self.map.addLayer(self.marker)
def _load_data(self): with open(self.data_path) as data_in: self.data = json.load(data_in) years = [int(year) for year in self.data['incidents']] self._getMaxIncidents() # We want to create markers for each country based on number # of incidents and save them for every year in the dataset self.yearLayers = {} for year in self.data['incidents']: self.yearLayers[year] = [] for country in self.data['incidents'][year]: coords = self.data['countries'][country]['coordinates'] number = self.data['incidents'][year][country] radius = self._getMarkerRadius(number) # While creating markers, options can also be passed yearMarker = L.circleMarker(coords, { 'radius': radius, 'color': '#C62828', 'weight': 1 }) # A popup allows extra data to be shown on click of the marker yearMarker.bindPopup( 'In {year}, {country} has {number} incidents of polio reported' .format(year=year, country=country, number=number)) self.yearLayers[year].append(yearMarker) # Initialise the slider based on the data self.yearSlider.setMinimum(min(years)) self.yearSlider.setMaximum(max(years)) self.yearLabel.setText(str(min(years)))
def __init__(self): # Setting up the widgets and layout super().__init__() self.mapWidget = MapWidget() self.button_refresh = QPushButton('Refresh') self.layout = QVBoxLayout() self.layout.addWidget(self.mapWidget) self.layout.addWidget(self.button_refresh) self.button_refresh.clicked.connect(self.refresh_data) self.setLayout(self.layout) # Working with the maps with pyqtlet self.map = L.map(self.mapWidget) self.map.setView([47.377621, 8.541238], 12.25) L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map) self.marker = L.marker([47.404749, 8.554875]) self.marker.bindPopup('Maps are a treasure.') self.map.addLayer(self.marker) self.show()
def __init__(self, parent, settings): super().__init__() self._page.profile().setHttpUserAgent("Activate") self.settings = settings size_policy = self.sizePolicy() size_policy.setRetainSizeWhenHidden(True) self.setSizePolicy(size_policy) self.setContextMenuPolicy(Qt.NoContextMenu) self.map = L.map(self) if settings.tiles is None: L.tileLayer( "http://{s}.tile.osm.org/{z}/{x}/{y}.png", { "attribution": "© OpenStreetMap contributors" }, ).addTo(self.map) else: L.tileLayer(settings.tiles, {"attribution": ""}).addTo(self.map) self.map.runJavaScript( f"{self.map.jsName}.attributionControl.setPrefix('');") self.moved = False
def __init__(self, planes): super().__init__() self.mapWidget = MapWidget() self.layout = QVBoxLayout() self.layout.addWidget(self.mapWidget) self.setLayout(self.layout) self.map = L.map(self.mapWidget) self.map.setView([26.8022, 30.8025], 6) L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map) for plane in planes: print(plane) self.marker = L.marker([plane[0], plane[1]]) self.marker.bindPopup("Lat : " + str(plane[0]) + " ,Lon : " + str(plane[1])) self.map.addLayer(self.marker) latlngs = [[26.8022, 30.8888], [27.8206, 31.8025], [28.8206, 32.8025]] polyline = L.polyline(latlngs).addTo(self.map); self.show()
def refresh_data(self): self.marker = L.circleMarker([47.404749-uniform(-1,1)/50, 8.554875-uniform(-1,1)/50], {'radius': 5, 'color': '#C62828', 'className': 'L'}) self.map.addLayer(self.marker) self.show()
def set_marker(self, lat, lon, ssid): marker = L.marker([lat, lon]) marker.bindPopup(ssid) self.map.addLayer(marker) self.markers.append(marker)