mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-07-13 16:16:44 +02:00
debugging map failure
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
package kst4contest.view.map;
|
package kst4contest.view.map;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML host for the JavaFX WebView map.
|
* HTML host for the JavaFX WebView map.
|
||||||
*
|
*
|
||||||
@@ -16,7 +21,21 @@ public final class MapHtmlResources {
|
|||||||
private MapHtmlResources() {
|
private MapHtmlResources() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String readRequiredResource(String resourcePath) {
|
||||||
|
try (InputStream inputStream = MapHtmlResources.class.getResourceAsStream(resourcePath)) {
|
||||||
|
if (inputStream == null) {
|
||||||
|
throw new IllegalStateException("Missing map resource: " + resourcePath);
|
||||||
|
}
|
||||||
|
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException exception) {
|
||||||
|
throw new UncheckedIOException("Could not read map resource: " + resourcePath, exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String createStationMapHtml() {
|
public static String createStationMapHtml() {
|
||||||
|
String leafletCss = readRequiredResource("/web/leaflet/leaflet.css");
|
||||||
|
String leafletJs = readRequiredResource("/web/leaflet/leaflet.js");
|
||||||
|
|
||||||
return """
|
return """
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@@ -24,10 +43,9 @@ public final class MapHtmlResources {
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>KST4Contest Station Map</title>
|
<title>KST4Contest Station Map</title>
|
||||||
<link rel="stylesheet"
|
<style>
|
||||||
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
""" + leafletCss + """
|
||||||
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
|
</style>
|
||||||
crossorigin="">
|
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--map-background: #ede9df;
|
--map-background: #ede9df;
|
||||||
@@ -196,9 +214,9 @@ public final class MapHtmlResources {
|
|||||||
<body class="kst-theme-light">
|
<body class="kst-theme-light">
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
|
|
||||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
<script>
|
||||||
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
""" + leafletJs + """
|
||||||
crossorigin=""></script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
@@ -336,7 +354,12 @@ public final class MapHtmlResources {
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (map) {
|
if (map) {
|
||||||
return;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof L === 'undefined') {
|
||||||
|
jsError('Leaflet is not loaded. Station map cannot initialize.');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyThemeClass();
|
applyThemeClass();
|
||||||
@@ -385,6 +408,7 @@ public final class MapHtmlResources {
|
|||||||
|
|
||||||
notifyMapReady();
|
notifyMapReady();
|
||||||
notifyViewport();
|
notifyViewport();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function invalidateSize() {
|
function invalidateSize() {
|
||||||
@@ -468,13 +492,17 @@ public final class MapHtmlResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setHome(lat, lon, zoom) {
|
function setHome(lat, lon, zoom) {
|
||||||
init();
|
if (!init()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
jsLog('setHome lat=' + lat + ' lon=' + lon + ' zoom=' + zoom);
|
jsLog('setHome lat=' + lat + ' lon=' + lon + ' zoom=' + zoom);
|
||||||
map.setView([lat, lon], zoom);
|
map.setView([lat, lon], zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStations(stationsJson) {
|
function setStations(stationsJson) {
|
||||||
init();
|
if (!init()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
stationLayer.clearLayers();
|
stationLayer.clearLayers();
|
||||||
markersByCallsignRaw = {};
|
markersByCallsignRaw = {};
|
||||||
@@ -503,7 +531,9 @@ public final class MapHtmlResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setBeam(beamJson) {
|
function setBeam(beamJson) {
|
||||||
init();
|
if (!init()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
beamLayer.clearLayers();
|
beamLayer.clearLayers();
|
||||||
|
|
||||||
if (!beamJson || beamJson === 'null') {
|
if (!beamJson || beamJson === 'null') {
|
||||||
@@ -530,7 +560,9 @@ public final class MapHtmlResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setConnection(connectionJson) {
|
function setConnection(connectionJson) {
|
||||||
init();
|
if (!init()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
connectionLayer.clearLayers();
|
connectionLayer.clearLayers();
|
||||||
|
|
||||||
if (!connectionJson || connectionJson === 'null') {
|
if (!connectionJson || connectionJson === 'null') {
|
||||||
@@ -555,7 +587,9 @@ public final class MapHtmlResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setProfileHoverPoint(point) {
|
function setProfileHoverPoint(point) {
|
||||||
init();
|
if (!init()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (profileHoverMarker) {
|
if (profileHoverMarker) {
|
||||||
map.removeLayer(profileHoverMarker);
|
map.removeLayer(profileHoverMarker);
|
||||||
@@ -584,7 +618,9 @@ public final class MapHtmlResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setGrid(gridJson) {
|
function setGrid(gridJson) {
|
||||||
init();
|
if (!init()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
gridLayer.clearLayers();
|
gridLayer.clearLayers();
|
||||||
|
|
||||||
const cells = JSON.parse(gridJson);
|
const cells = JSON.parse(gridJson);
|
||||||
|
|||||||
Reference in New Issue
Block a user