File: examples.rst

package info (click to toggle)
python-pyqtlet2 0.9.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,672 kB
  • sloc: python: 997; javascript: 88; makefile: 18; sh: 14
file content (39 lines) | stat: -rw-r--r-- 966 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Examples
========

Simple Setup App
----------------

This is a simple app that sets up pyqtlet and shows the basic functionality of the
package.

.. code:: python

	import sys
	from qtpy.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])
		self.marker.bindPopup('Maps are a treasure.')
		self.map.addLayer(self.marker)
		self.show()

	if __name__ == '__main__':
	    app = QApplication(sys.argv)
	    widget = MapWindow()
	    sys.exit(app.exec_())