Image image = new Image("https://tile.openstreetmap.org/1/1/0.png");
2019年开始OpenStreetMap的瓦片不能直接用了,在JavaFX中作为Image时必须加入代理才能加载显示。
static final String httpAgent;
static {
String agent = System.getProperty("http.agent");
if (agent == null) {
agent = "(" + System.getProperty("os.name") + " / " + System.getProperty("os.version") + " / " + System.getProperty("os.arch") + ")";
}
httpAgent = "Gluon Maps/2.0.0 " + agent;
System.setProperty("http.agent", httpAgent);
}