Added map type selection to the settings.

This commit is contained in:
Marat Fayzullin 2023-08-07 16:14:25 -04:00
parent 8bdaf9e132
commit 7dd243ab02
7 changed files with 26 additions and 3 deletions

View File

@ -17,7 +17,7 @@
<div class="openwebrx-map-legend">
<div id="openwebrx-map-selectors">
<h3>Colors</h3>
<select id="openwebrx-map-colormode">
<select style="width:100%;" id="openwebrx-map-colormode">
<option value="byband" selected="selected">By Band</option>
<option value="bymode">By Mode</option>
<option value="off">Off</option>

View File

@ -16,8 +16,15 @@
<div class="openwebrx-map" id="openwebrx-map"></div>
<div class="openwebrx-map-legend">
<div id="openwebrx-map-selectors">
<h3>Map</h3>
<select style="width:100%;" id="openwebrx-map-source">
<option value="osm" selected="selected">OpenStreetMap</option>
<option value="stadia">Stadia</option>
<option value="esri">ESRIWorldTopo</option>
<option value="opentopomap">OpenTopoMap</option>
</select>
<h3>Colors</h3>
<select id="openwebrx-map-colormode">
<select style="width:100%;" id="openwebrx-map-colormode">
<option value="byband" selected="selected">By Band</option>
<option value="bymode">By Mode</option>
<option value="off">Off</option>

View File

@ -165,6 +165,7 @@ defaultConfig = PropertyLayer(
tuning_precision=2,
squelch_auto_margin=10,
google_maps_api_key="",
map_type="google",
map_position_retention_time=2 * 60 * 60,
map_prefer_recent_reports=True,
map_ignore_indirect_reports=False,

View File

@ -486,6 +486,7 @@ class MapConnection(OpenWebRxClient):
filtered_config = pm.filter(
"google_maps_api_key",
"receiver_gps",
"map_type",
"map_position_retention_time",
"map_ignore_indirect_reports",
"map_prefer_recent_reports",

View File

@ -207,6 +207,14 @@ class GeneralSettingsController(SettingsFormController):
),
Section(
"Map settings",
DropdownInput(
"map_type",
"Map type",
options=[
Option("google", "Google Maps"),
Option("leaflet", "OpenStreetMap, etc."),
],
),
TextInput(
"google_maps_api_key",
"Google Maps API key",

View File

@ -1,5 +1,6 @@
from owrx.controllers import Controller
from owrx.details import ReceiverDetails
from owrx.config import Config
from string import Template
import pkg_resources
@ -42,7 +43,8 @@ class IndexController(WebpageController):
class MapController(WebpageController):
def indexAction(self):
# TODO check if we have a google maps api key first?
self.serve_template("map-google.html", **self.template_variables())
pm = Config.get()
self.serve_template("map-%s.html" % pm["map_type"], **self.template_variables())
class PolicyController(WebpageController):

View File

@ -358,6 +358,7 @@ EIBI_Countries = {
"EEu": "Eastern Europe",
"ENA": "Eastern North America",
"ENE": "East-Northeast",
"EOc": "Eastern Oceania",
"ESE": "East-Southeast",
"Eu" : "Europe, incl. North Africa / Middle East",
"FE" : "Far East",
@ -374,6 +375,7 @@ EIBI_Countries = {
"NE" : "Northeast",
"NNE": "North-Northeast",
"NNW": "North-Northwest",
"NOc": "North Oceania",
"NW" : "Northwest",
"Oc" : "Oceania (Australia, New Zealand, Pacific Ocean)",
"S..": "South ..",
@ -386,6 +388,7 @@ EIBI_Countries = {
"SEA": "South East Asia",
"SEE": "South East Europe",
"Sib": "Siberia",
"SOc": "South Oceania",
"SSE": "South-Southeast",
"SSW": "South-Southwest",
"SW" : "Southwest",
@ -397,6 +400,7 @@ EIBI_Countries = {
"WIO": "Western Indian Ocean",
"WNA": "Western North America",
"WNW": "West-Northwest",
"WOc": "Western Oceania",
"WSW": "West-Southwest",
# ITU codes start here
"ABW": "Aruba",