add google maps

This commit is contained in:
Jakob Ketterl
2019-07-01 19:49:58 +02:00
parent 893f69ad18
commit 2324a2c837
5 changed files with 84 additions and 17 deletions

4
htdocs/map.css Normal file
View File

@ -0,0 +1,4 @@
html, body {
width: 100%;
height: 100%;
}

View File

@ -4,7 +4,7 @@
<title>OpenWebRX | Open Source SDR Web App for Everyone!</title>
<script src="static/jquery-3.2.1.min.js"></script>
<script src="static/map.js"></script>
<link rel="stylesheet" type="text/css" href="static/nanoscroller.css" />
<link rel="stylesheet" type="text/css" href="static/map.css" />
<meta charset="utf-8">
</head>
<body>

View File

@ -9,11 +9,38 @@
var ws = new WebSocket(ws_url);
ws.onopen = function(){
console.info("onopen");
ws.send("SERVER DE CLIENT client=map.js type=map");
};
ws.onmessage = function(){
console.info("onmessage");
ws.onmessage = function(e){
if (typeof e.data != 'string') {
console.error("unsupported binary data on websocket; ignoring");
return
}
if (e.data.substr(0, 16) == "CLIENT DE SERVER") {
console.log("Server acknowledged WebSocket connection.");
return
}
try {
json = JSON.parse(e.data);
switch (json.type) {
case "config":
var config = json.value;
$.getScript("https://maps.googleapis.com/maps/api/js?key=" + config.google_maps_api_key).done(function(){
var map = new google.maps.Map($('body')[0], {
center: {
lat: config.receiver_gps[0],
lng: config.receiver_gps[1]
},
zoom: 8
});
})
break
}
} catch (e) {
// don't lose exception
console.error(e);
}
};
ws.onclose = function(){
console.info("onclose");