Leaflet Routing Machine / GraphHopper

220 views
Skip to first unread message

Dominik Hanser

unread,
Jul 18, 2016, 5:01:56 AM7/18/16
to Leaflet
I am using the Leaflet API to show a map in a JavaFX application. I'm using a WebView to visualize the website with the map in my application. 
The application shows a driving simulation of a car between some Points. 
If I use the OSMR Routing i don't have any problems to visualize the website & the map. 

The problem is that I have to use the GraphHopper routing machine.

If I use the GraphHopper routing the control elements of the map will be shown, 
but the map is only grey. 

If I open the website in a browser I don't have any problems.

Here is the Code of the Map 

<body>
    <div id="map" class="map"></div>
    <script src="rm/dist/leaflet-routing-machine.js"></script>
<script src="rm/lrm-graphhopper.js"></script>
    <script type="text/javascript">
    var map = L.map('map');

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

    L.Routing.control({
    waypoints: [
    L.latLng(57.74, 11.94),
    L.latLng(57.6792, 11.949)
    ],
    routeWhileDragging: true
    }).addTo(map);
    </script>
</body>

And this is the code of the javaFX application: 

WebEngine webEngine = webView.getEngine();
webEngine.setJavaScriptEnabled(true);
webEngine.load(Main.class.getResource("/application/index.html").toExternalForm() );

Can anybody help me ?

Reply all
Reply to author
Forward
0 new messages