I am trying to load google map on JavaFx-WebView, and it doesn't show anything except background color of html body that i have coded on html file. Also i tried some examples on Google search, all the result were older. None of it works. My Java version is "1.8.0_121"
I wrote a html file & run it. It loaded google maps successfully. Then i load the html file to webview using webEngine.load("path") method. it doesn't show anything except backgound color.
After that I tried http://rterp.github.io/GMapsFX
Also i couldn't find any solutions for this error
Html File
CSS:
#map_canvas { height: 100%; background-color: blue; }
javascript:
function initialize() {
var latlng = new google.maps.LatLng(37.39822, -121.9643936);
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
navigationControl: false,
streetViewControl: false,
backgroundColor: "#666970"
};
document.geocoder = new google.maps.Geocoder();
document.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
html:
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
JavaFX:
public class WebMap extends Application {
@Override public void start(Stage stage) {
// create web engine and view
final WebView webView = new WebView();
final WebEngine webEngine = webView.getEngine();
webEngine.load(getClass().getResource("WebMap.html").toString());
// create scene
stage.setTitle("Web Map");
Scene scene = new Scene(webView,1000,700, Color.web("#666970"));
stage.setScene(scene);
// show stage
stage.show();
}
public static void main(String[] args){
Application.launch(args);
}
}
Google maps API dropped support for older browsers which started causing the "The Google Maps JavaScript API does not support this browser." error. Look at https://developers.google.com/maps/documentation/javascript/releases and https://developers.google.com/maps/documentation/javascript/versions.
The library you are using is using version 3.exp (experimental).
Running on a newer Java version will fix this (for now).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With