1

i have a java class as below:

package client;

import java.io.IOException;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class Test extends Application {
    @Override
    public void start(Stage stage) throws Exception {
        StackPane root = new StackPane();

        WebView view = new WebView();
        WebEngine engine = view.getEngine();
        engine.load(Test.class.getResource("/mapview/leafDani.html").toExternalForm());
        root.getChildren().add(view);

        Scene scene = new Scene(root, 700, 700);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) throws IOException {
        Application.launch(args);
    }
}

the html file i made load an opnestreetmap center on london:

<!DOCTYPE html>

<html>

<head>
    <title>Daniele test map</title>

    <link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.3/dist/leaflet.css" />

    <script src="https://npmcdn.com/leaflet@1.0.0-rc.3/dist/leaflet.js"></script>

    <style>
        #map {
            width: 700px;
            height:700px;
        }
    </style>

</head>

<body>

<div id="map"></div>

<script>

    function jumpTo(lon, lat, zoom) {

        map.setView(new L.LatLng(lat, lon), zoom);
    }

    var map = L.map('map').setView([51.505, -0.09], 13);

    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);


</script>

</body>

</html>

when i start the application the page seems to be loaded, i can see the button for zoom in and zoom out but the map doesn't appear or partially appear. if i open the html file with my browser is perfect. im using intellij as IDE and i even tried to modify the defualt browser but i got the same resoult. any suggestions?

Daniele_r81
  • 123
  • 3
  • 14
  • To figure out what happens there you probably need to debug the `WebView`. You can do this as described in http://stackoverflow.com/questions/9398879/html-javascript-debugging-in-javafx-webview – hotzst Sep 01 '16 at 12:03
  • i tried what jewelsea suggest but it doesn't work in my case. i tried to load http://docs.oracle.com/javafx/2/get_started/animation.htm instead of my html file and it works but the debug say that javascript is not enabled...i check my browser and it is enabled, any other suggestions ? – Daniele_r81 Sep 01 '16 at 13:09
  • JavaFX uses a native implementation of the WebKit behind the WebView. This has nothing to do with the browser you usually use in your OS. – hotzst Sep 01 '16 at 13:18
  • so what should i check ? – Daniele_r81 Sep 01 '16 at 14:02

0 Answers0