fix Pipeline Modules n map Linux
This commit is contained in:
@@ -32,7 +32,7 @@ public final class MapHtmlResources {
|
||||
}
|
||||
}
|
||||
|
||||
public static String createStationMapHtml() {
|
||||
public static String createStationMapHtml(int tileProxyPort) {
|
||||
String leafletCss = readRequiredResource("/web/leaflet/leaflet.css");
|
||||
String leafletJs = readRequiredResource("/web/leaflet/leaflet.js");
|
||||
|
||||
@@ -217,6 +217,7 @@ public final class MapHtmlResources {
|
||||
<script>
|
||||
""" + leafletJs + """
|
||||
</script>
|
||||
<script>window._kstTileProxyPort=__TILE_PROXY_PORT__;</script>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -370,21 +371,13 @@ public final class MapHtmlResources {
|
||||
|
||||
jsLog('Leaflet map initialized');
|
||||
|
||||
const osmTileLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
});
|
||||
|
||||
osmTileLayer.on('tileload', function (event) {
|
||||
jsLog('OSM tile loaded');
|
||||
});
|
||||
|
||||
osmTileLayer.on('tileerror', function (event) {
|
||||
const src = event && event.tile ? event.tile.src : 'unknown';
|
||||
jsError('OSM tile load failed: ' + src);
|
||||
});
|
||||
|
||||
osmTileLayer.addTo(map);
|
||||
L.tileLayer(
|
||||
'http://127.0.0.1:' + window._kstTileProxyPort + '/tiles/{s}/{z}/{x}/{y}.png',
|
||||
{
|
||||
maxZoom: 18,
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
}
|
||||
).addTo(map);
|
||||
|
||||
map.createPane('beamPane');
|
||||
map.getPane('beamPane').style.zIndex = 410;
|
||||
@@ -717,6 +710,6 @@ public final class MapHtmlResources {
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
""".replace("__TILE_PROXY_PORT__", String.valueOf(tileProxyPort));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import kst4contest.ApplicationConstants;
|
||||
import kst4contest.locatorUtils.Location;
|
||||
import kst4contest.model.ChatPreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -48,6 +49,7 @@ public final class StationMapView {
|
||||
private final Stage stage = new Stage();
|
||||
private final WebView webView = new WebView();
|
||||
private final WebEngine webEngine = webView.getEngine();
|
||||
private TileProxyServer tileProxyServer;
|
||||
|
||||
private Scene scene;
|
||||
private BorderPane rootPane;
|
||||
@@ -127,6 +129,11 @@ public final class StationMapView {
|
||||
|
||||
public StationMapView(ChatPreferences chatPreferences) {
|
||||
this.chatPreferences = Objects.requireNonNull(chatPreferences, "chatPreferences");
|
||||
try {
|
||||
tileProxyServer = new TileProxyServer();
|
||||
} catch (IOException e) {
|
||||
System.err.println("[StationMap] tile proxy failed to start: " + e.getMessage());
|
||||
}
|
||||
initializeUi();
|
||||
initializeWebView();
|
||||
}
|
||||
@@ -627,9 +634,8 @@ public final class StationMapView {
|
||||
}
|
||||
});
|
||||
|
||||
webEngine.setUserAgent("KST4Contest (+https://hamradioonline.de)");
|
||||
|
||||
webEngine.loadContent(MapHtmlResources.createStationMapHtml());
|
||||
int proxyPort = tileProxyServer != null ? tileProxyServer.getPort() : 0;
|
||||
webEngine.loadContent(MapHtmlResources.createStationMapHtml(proxyPort));
|
||||
}
|
||||
|
||||
private void requestMapInvalidateSize() {
|
||||
@@ -1446,4 +1452,4 @@ public final class StationMapView {
|
||||
|
||||
return storedSize[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user