1

I am try to view google map on the desktop application but the map is not visible on the screen.

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();
}

When I run the code, it run correct but the map will not display and show exception in logs........................

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)
2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.