Merge pull request #84 from devnulling/master

Add API Field, update markerwithlabel.js source
This commit is contained in:
bistromath 2016-05-17 15:59:24 -07:00
commit e8c2a47278
3 changed files with 49 additions and 14 deletions

View File

@ -87,6 +87,8 @@ class mainwindow(QtGui.QMainWindow):
self.ui.line_my_lat.insert(defaults["latitude"]) self.ui.line_my_lat.insert(defaults["latitude"])
if defaults["longitude"] is not None: if defaults["longitude"] is not None:
self.ui.line_my_lon.insert(defaults["longitude"]) self.ui.line_my_lon.insert(defaults["longitude"])
if defaults["apikey"] is not None:
self.ui.line_my_api_key.insert(defaults["apikey"])
#disable by default #disable by default
self.ui.check_adsbonly.setCheckState(QtCore.Qt.Unchecked) self.ui.check_adsbonly.setCheckState(QtCore.Qt.Unchecked)
@ -321,6 +323,11 @@ class mainwindow(QtGui.QMainWindow):
except: except:
my_position = None my_position = None
try:
my_apikey = str(self.ui.line_my_api_key.text())
except:
my_apikey = None
self._cpr_dec = air_modes.cpr_decoder(my_position) self._cpr_dec = air_modes.cpr_decoder(my_position)
self.datamodelout = dashboard_output(self._cpr_dec, self.datamodel, self._publisher) self.datamodelout = dashboard_output(self._cpr_dec, self.datamodel, self._publisher)
@ -359,7 +366,7 @@ class mainwindow(QtGui.QMainWindow):
#create SQL database for KML and dashboard displays #create SQL database for KML and dashboard displays
self.dbwriter = air_modes.output_sql(self._cpr_dec, self.dbname, self.lock, self._publisher) self.dbwriter = air_modes.output_sql(self._cpr_dec, self.dbname, self.lock, self._publisher)
self.jsonpgen = air_modes.output_jsonp(self._jsonfile.name, self.dbname, my_position, self.lock, timeout=1) self.jsonpgen = air_modes.output_jsonp(self._jsonfile.name, self.dbname, my_position, self.lock, timeout=1)
htmlstring = air_modes.html_template(my_position, self._jsonfile.name) htmlstring = air_modes.html_template(my_apikey, my_position, self._jsonfile.name)
self._htmlfile.write(htmlstring) self._htmlfile.write(htmlstring)
self._htmlfile.flush() self._htmlfile.flush()
class WebPage(QtWebKit.QWebPage): class WebPage(QtWebKit.QWebPage):
@ -404,6 +411,10 @@ class mainwindow(QtGui.QMainWindow):
self.prefs["longitude"] = float(self.ui.line_my_lon.text()) self.prefs["longitude"] = float(self.ui.line_my_lon.text())
except: except:
pass pass
try:
self.prefs["apikey"] = self.ui.line_my_api_key.text()
except:
pass
def on_quit(self): def on_quit(self):
if self.running is True: if self.running is True:
@ -463,6 +474,7 @@ class mainwindow(QtGui.QMainWindow):
defaults["threshold"] = "5" defaults["threshold"] = "5"
defaults["latitude"] = None defaults["latitude"] = None
defaults["longitude"] = None defaults["longitude"] = None
defaults["apikey"] = None
prefs = ConfigParser.ConfigParser(defaults) prefs = ConfigParser.ConfigParser(defaults)
prefs.optionxform = str prefs.optionxform = str

View File

@ -2,7 +2,7 @@
#HTML template for Mode S map display #HTML template for Mode S map display
#Nick Foster, 2013 #Nick Foster, 2013
def html_template(my_position, json_file): def html_template(my_apikey, my_position, json_file):
if my_position is None: if my_position is None:
my_position = [37, -122] my_position = [37, -122]
@ -25,9 +25,9 @@ def html_template(my_position, json_file):
white-space: nowrap; white-space: nowrap;
} }
</style> </style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> <script type="text/javascript" src="http://maps.google.com/maps/api/js?key=%s">
</script> </script>
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.9/src/markerwithlabel.js"> <script type="text/javascript" src="https://raw.githubusercontent.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js">
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var map; var map;
@ -152,4 +152,4 @@ def html_template(my_position, json_file):
<div id="map_canvas" style="width:100%%; height:100%%"> <div id="map_canvas" style="width:100%%; height:100%%">
</div> </div>
</body> </body>
</html>""" % (my_position[0], my_position[1], json_file) </html>""" % (my_apikey, my_position[0], my_position[1], json_file)

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>687</width> <width>719</width>
<height>422</height> <height>454</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -102,8 +102,8 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>236</width> <width>241</width>
<height>251</height> <height>281</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -307,7 +307,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>200</y> <y>190</y>
<width>221</width> <width>221</width>
<height>22</height> <height>22</height>
</rect> </rect>
@ -320,7 +320,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>220</y> <y>210</y>
<width>221</width> <width>221</width>
<height>22</height> <height>22</height>
</rect> </rect>
@ -329,6 +329,16 @@
<string>Use DC blocking filter</string> <string>Use DC blocking filter</string>
</property> </property>
</widget> </widget>
<widget class="QLineEdit" name="line_my_api_key">
<property name="geometry">
<rect>
<x>90</x>
<y>250</y>
<width>121</width>
<height>27</height>
</rect>
</property>
</widget>
</widget> </widget>
<widget class="QGroupBox" name="group_output"> <widget class="QGroupBox" name="group_output">
<property name="geometry"> <property name="geometry">
@ -549,6 +559,19 @@
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QLabel" name="label_34">
<property name="geometry">
<rect>
<x>20</x>
<y>270</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>API Key</string>
</property>
</widget>
</widget> </widget>
<widget class="QWidget" name="dashboard"> <widget class="QWidget" name="dashboard">
<attribute name="title"> <attribute name="title">
@ -1031,7 +1054,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>687</width> <width>719</width>
<height>25</height> <height>25</height>
</rect> </rect>
</property> </property>