-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow
134 lines (120 loc) · 4.04 KB
/
mainwindow
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from PyQt5 import uic, QtWebEngineWidgets, QtWebChannel, QtGui, QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
import pyqtgraph as pg
from pyqtgraph import PlotWidget, plot
import sys
import os
maphtml = '''<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Circles</title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// This example creates circles on the map, representing populations in North
// America.
// First, create an object containing LatLng and population for each city.
var citymap = {
chicago: {
center: {lat: 41.878, lng: -87.629},
population: 2714856
},
newyork: {
center: {lat: 40.714, lng: -74.005},
population: 8405837
},
losangeles: {
center: {lat: 34.052, lng: -118.243},
population: 3857799
},
vancouver: {
center: {lat: 49.25, lng: -123.1},
population: 603502
}
};
function initMap() {
// Create the map.
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: {lat: 37.090, lng: -95.712},
mapTypeId: 'terrain'
});
// Construct the circle for each value in citymap.
// Note: We scale the area of the circle based on the population.
for (var city in citymap) {
// Add the circle for this city to the map.
var cityCircle = new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: citymap[city].center,
radius: Math.sqrt(citymap[city].population) * 100
});
}
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBRXytt0uc8F7UXVOZFSE7dXelO2MQn31Q&callback=initMap">
</script>
</body>
</html>'''
path = r'C:\Users\danie\PycharmProjects\MapProject\nyu.html'
folium_html = QtCore.QUrl.fromLocalFile(path)
#maphtml.replace('YOUR_API_KEY', 'AIzaSyBRXytt0uc8F7UXVOZFSE7dXelO2MQn31Q')
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(QMainWindow, self).__init__(*args,**kwargs)
self.title = 'MapView'
self.map_widget = MapWidget(self)
_widget = QtGui.QWidget()
_layout = QtGui.QVBoxLayout(_widget)
_layout.addWidget(self.map_widget)
self.setCentralWidget(_widget)
class MapWidget(QWidget):
def __init__(self, parent):
super(MapWidget, self).__init__(parent)
self.__controls()
self.__layout()
# self.setCentralWidget(self.main_widget)
def __controls(self):
self.label = QtGui.QLabel('Testing this')
# generate maps
self.main_widget = QtWebEngineWidgets.QWebEngineView()
#self.main_widget.setHtml(folium_html)
self.main_widget.load(folium_html)
def __layout(self):
self.vbox = QtGui.QVBoxLayout()
self.hbox = QtGui.QHBoxLayout()
#self.main_layout = QVBoxLayout(self.main_widget)
self.hbox.addWidget(self.main_widget)
self.hbox.addWidget(self.label)
self.vbox.addLayout(self.hbox)
self.setLayout(self.vbox)
if __name__ == "__main__":
sys.argv.append('--disable-web-security')
app = QApplication(sys.argv)
w = MainWindow()
#w.setHtml(maphtml)
w.resize(800, 600)
w.show()
sys.exit(app.exec_())