java.lang.Object
com.example.cab302project.TileProxyServer
A lightweight local HTTP tile proxy server for JavaFX WebView.
JavaFX's WebView on macOS (WebKit) blocks external network requests to
tile servers (e.g. openstreetmap.org), causing the map tiles to fail.
On Windows the tiles load but slowly due to WebKit's limited concurrency.
This server binds to localhost on a random available port and proxies
tile requests using Java's HttpURLConnection, which has no such
restrictions. WebView talks to localhost (always allowed), and this
server fetches the real tiles transparently.
Three tile styles are available via separate URL paths:
/tile/ - OpenStreetMap standard tiles
/cartodblight/ - CartoDB Positron light grey minimal style
/cartodbdark/ - CartoDB Dark Matter dark navy style (used by default)
Usage:
TileProxyServer server = new TileProxyServer();
server.start();
int port = server.getPort();
server.stop();
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TileProxyServer
public TileProxyServer()
-
-
Method Details
-
start
Starts the tile proxy on a random available port.- Throws:
IOException- if the server cannot bind to a port.
-
stop
public void stop()Stops the tile proxy server. -
getPort
public int getPort()Returns the port the server is listening on.
-