send changed keys over websocket connection for the map
This commit is contained in:
parent
7dcafab2c1
commit
e9cb5d54be
@ -1,4 +1,4 @@
|
|||||||
(function(){
|
$(function(){
|
||||||
var query = window.location.search.replace(/^\?/, '').split('&').map(function(v){
|
var query = window.location.search.replace(/^\?/, '').split('&').map(function(v){
|
||||||
var s = v.split('=');
|
var s = v.split('=');
|
||||||
var r = {};
|
var r = {};
|
||||||
@ -212,6 +212,8 @@
|
|||||||
|
|
||||||
var reconnect_timeout = false;
|
var reconnect_timeout = false;
|
||||||
|
|
||||||
|
var config = {}
|
||||||
|
|
||||||
var connect = function(){
|
var connect = function(){
|
||||||
var ws = new WebSocket(ws_url);
|
var ws = new WebSocket(ws_url);
|
||||||
ws.onopen = function(){
|
ws.onopen = function(){
|
||||||
@ -225,14 +227,14 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (e.data.substr(0, 16) == "CLIENT DE SERVER") {
|
if (e.data.substr(0, 16) == "CLIENT DE SERVER") {
|
||||||
console.log("Server acknowledged WebSocket connection.");
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var json = JSON.parse(e.data);
|
var json = JSON.parse(e.data);
|
||||||
switch (json.type) {
|
switch (json.type) {
|
||||||
case "config":
|
case "config":
|
||||||
var config = json.value;
|
Object.assign(config, json.value);
|
||||||
|
if ('receiver_gps' in config) {
|
||||||
var receiverPos = {
|
var receiverPos = {
|
||||||
lat: config.receiver_gps.lat,
|
lat: config.receiver_gps.lat,
|
||||||
lng: config.receiver_gps.lon
|
lng: config.receiver_gps.lon
|
||||||
@ -272,11 +274,18 @@
|
|||||||
receiverMarker.setOptions({
|
receiverMarker.setOptions({
|
||||||
map: map,
|
map: map,
|
||||||
position: receiverPos,
|
position: receiverPos,
|
||||||
title: config['receiver_name'],
|
|
||||||
config: config
|
config: config
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ('receiver_name' in config && receiverMarker) {
|
||||||
|
receiverMarker.setOptions({
|
||||||
|
title: config['receiver_name']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ('map_position_retention_time' in config) {
|
||||||
retention_time = config.map_position_retention_time * 1000;
|
retention_time = config.map_position_retention_time * 1000;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "update":
|
case "update":
|
||||||
processUpdates(json.value);
|
processUpdates(json.value);
|
||||||
@ -464,4 +473,4 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
@ -459,14 +459,15 @@ class MapConnection(OpenWebRxClient):
|
|||||||
super().__init__(conn)
|
super().__init__(conn)
|
||||||
|
|
||||||
pm = Config.get()
|
pm = Config.get()
|
||||||
self.write_config(
|
filtered_config = pm.filter(
|
||||||
pm.filter(
|
|
||||||
"google_maps_api_key",
|
"google_maps_api_key",
|
||||||
"receiver_gps",
|
"receiver_gps",
|
||||||
"map_position_retention_time",
|
"map_position_retention_time",
|
||||||
"receiver_name",
|
"receiver_name",
|
||||||
).__dict__()
|
|
||||||
)
|
)
|
||||||
|
filtered_config.wire(self.write_config)
|
||||||
|
|
||||||
|
self.write_config(filtered_config.__dict__())
|
||||||
|
|
||||||
Map.getSharedInstance().addClient(self)
|
Map.getSharedInstance().addClient(self)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user