Я пытаюсь просмотреть карту Google в настольном приложении, но карта не отображается на экране.
GMapsFX-2.12.0
protected DirectionsService directionsService;
protected DirectionsPane directionsPane;
protected StringProperty from = new SimpleStringProperty();
protected StringProperty to = new SimpleStringProperty();
@FXML
protected GoogleMapView mapView;
@FXML
protected TextField fromTextField;
@FXML
protected TextField toTextField;
@FXML
private void toTextFieldAction(ActionEvent event) {
DirectionsRequest request = new DirectionsRequest(from.get(), to.get(), TravelModes.DRIVING);
directionsService.getRoute(request, this, new DirectionsRenderer(true, mapView.getMap(), directionsPane));
}
@Override
public void directionsReceived(DirectionsResult results, DirectionStatus status) {
}
@Override
public void initialize(URL url, ResourceBundle rb) {
mapView.addMapInializedListener(this);
to.bindBidirectional(toTextField.textProperty());
from.bindBidirectional(fromTextField.textProperty());
}
@Override
public void mapInitialized() {
MapOptions options = new MapOptions();
options.center(new LatLong(47.606189, -122.335842))
.zoomControl(true)
.zoom(12)
.overviewMapControl(false)
.mapType(MapTypeIdEnum.ROADMAP);
GoogleMap map = mapView.createMap(options);
directionsService = new DirectionsService();
directionsPane = mapView.getDirec();
}
Когда я запускаю код,он работает правильно, но карта не будет отображаться и показывать исключения в журналах ........................
Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: ReferenceError: Can't find variable: google
at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:137)
at com.sun.webkit.WebPage.twkExecuteScript(Native Method)
at com.sun.webkit.WebPage.executeScript(WebPage.java:1482)
at javafx.scene.web.WebEngine.executeScript(WebEngine.java:1003)
at com.lynden.gmapsfx.javascript.JavaFxWebEngine.executeScript(JavaFxWebEngine.java:42)
at com.lynden.gmapsfx.GoogleMapView.initialiseScript(GoogleMapView.java:255)
at com.lynden.gmapsfx.GoogleMapView.access$000(GoogleMapView.java:53)
at com.lynden.gmapsfx.GoogleMapView$1.changed(GoogleMapView.java:214)
at com.lynden.gmapsfx.GoogleMapView$1.changed(GoogleMapView.java:211)