add google maps
This commit is contained in:
4
htdocs/map.css
Normal file
4
htdocs/map.css
Normal file
@ -0,0 +1,4 @@
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
@ -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>
|
||||
|
@ -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");
|
||||
|
Reference in New Issue
Block a user