parse and show locators on the map

This commit is contained in:
Jakob Ketterl 2019-07-06 22:43:36 +02:00
parent 48baea3304
commit 25bc788595

View File

@ -26,6 +26,7 @@
var map;
var markers = {};
var rectangles = {};
var updateQueue = [];
var processUpdates = function(updates) {
@ -34,8 +35,9 @@
return;
}
updates.forEach(function(update){
// TODO maidenhead locator implementation
if (update.location.type != 'latlon') return;
switch (update.location.type) {
case 'latlon':
var pos = new google.maps.LatLng(update.location.lat, update.location.lon)
if (markers[update.callsign]) {
markers[update.callsign].setPosition(pos);
@ -52,6 +54,34 @@
map.panTo(pos);
delete(expectedCallsign);
}
break;
case 'locator':
var loc = update.location.locator;
var lat = (loc.charCodeAt(1) - 65 - 9) * 10 + Number(loc[3]);
var lon = (loc.charCodeAt(0) - 65 - 9) * 20 + Number(loc[2]);
var rectangle;
if (rectangles[update.callsign]) {
rectangle = rectangles[update.callsign];
} else {
rectangle = new google.maps.Rectangle();
rectangles[update.callsign] = rectangle;
}
rectangle.setOptions({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
bounds:{
north: lat,
south: lat + 1,
west: lon,
east: lon + 1
}
});
break;
}
});
}