Javafx Gmapsfx 地图未正确加载的问题



我是新来的,所以我有一个问题。对于一个小项目,我必须创建一个javafx应用程序,我可以向用户显示从一个位置到另一个位置的路线。就像在Gmaps中一样。我搜索了一下,找到了gmapsfx并在我的代码中实现了库,因此加载了地图,但是有一个问题带有水印,这并不是一件坏事,因为这是一个学校项目,但是每当我打开应用程序时,它都会带有如下所示的警告屏幕:

在此处输入图像描述

https://github.com/rterp/GMapsFX/issues/149 这里它指出,当我使用特定的构造函数时,它应该解决这个问题,但它仍然没有帮助我。

此外,我尝试实现从 a 点到 b 点的导航,如下所示 https://rterp.wordpress.com/2016/08/22/mapping-directions-with-javafx-using-the-gmapsfx-directions-api/但它对我不起作用。我仍然是一个业余爱好者,所以我真的不知道问题是什么,我的控制台在日食中没有给出任何错误。也许我错过了一些东西,有人可以帮助我,请?

控制器类:

protected DirectionsService directionsService;
protected DirectionsPane directionsPane;
@FXML
protected GoogleMapView mapView = new GoogleMapView("de-DE", "My-Google-Map-API-Key");;

@FXML
private TextField startAirportField;
@FXML
private TextField targetField;
protected StringProperty from = new SimpleStringProperty();
protected StringProperty to = new SimpleStringProperty();
protected DirectionsRenderer directionsRenderer = null;
@FXML
private void toTextFieldAction() {
DirectionsRequest request = new DirectionsRequest(from.get(), to.get(), TravelModes.DRIVING);
directionsRenderer = new DirectionsRenderer(true, mapView.getMap(), directionsPane);
directionsService.getRoute(request, this, directionsRenderer);
}
@Override
public void directionsReceived(DirectionsResult results, DirectionStatus status) {
}

public void initialize() {
mapView.addMapInializedListener(this);
to.bindBidirectional(startAirportField.textProperty());
from.bindBidirectional(targetField.textProperty());
}
GoogleMap map ;
@Override
public void mapInitialized() {
MapOptions options = new MapOptions();

options.center(new LatLong(50.606189, -122.335842))
.zoomControl(true)
.zoom(12)
.overviewMapControl(false)
.mapType(MapTypeIdEnum.HYBRID);
map = mapView.createMap(options);
directionsService = new DirectionsService();
directionsPane = mapView.getDirec();
}

福美

<?xml version="1.0" encoding="UTF-8"?>
<?import com.lynden.gmapsfx.GoogleMapView?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" prefHeight="443.0" prefWidth="711.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.mapsViewController">
<children>
<GoogleMapView fx:id="mapView" layoutX="-311.0" layoutY="-244.0" prefWidth="490.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Text fx:id="startAirport" layoutX="50.0" layoutY="20.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Startflughafen" />
<Text fx:id="targetAirport" layoutX="250.0" layoutY="20.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Zielflughafen" />
<TextField fx:id="startAirportField" layoutX="50.0" layoutY="25.0" />
<TextField fx:id="targetField" layoutX="250.0" layoutY="25.0" />
<Button fx:id="drawLine" layoutX="425.0" layoutY="25.0" mnemonicParsing="false" onAction="#toTextFieldAction" text="Suche" />
</children></GoogleMapView>
</children>
</AnchorPane>

日食日志:

Dez 23, 2019 5:17:03 PM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 11.0.1 by JavaFX runtime of version 8.0.231
Dez 23, 2019 5:17:04 PM javafx.fxml.FXMLLoader$ValueElement processValue
WARNUNG: Loading FXML document with JavaFX API of version 11.0.1 by JavaFX runtime of version 8.0.231
[JavaFX Application Thread] INFO com.lynden.gmapsfx.GoogleMapView - Alert: Hide directions called
[JavaFX Application Thread] INFO com.lynden.gmapsfx.GoogleMapView - Alert: Hide directions called

protected GoogleMapViewmapView = new GoogleMapView("de-DE", "My-Google-Map-API-Key"(;;

预期的";">

相关内容

  • 没有找到相关文章