gpt4 book ai didi

java - gMapsFX netscape.javascript.JSException : ReferenceError

转载 作者:太空宇宙 更新时间:2023-11-04 10:40:08 26 4
gpt4 key购买 nike

我正在尝试在我的 javafx 程序中使用 gmapsfx。

我的代码是这样的:

@Override
public void initialize(URL url, ResourceBundle rb) {
mapView = new GoogleMapView();
mapView.addMapInializedListener(this);
}


@Override
public void mapInitialized() {
MapOptions options = new MapOptions();
options
.center(new LatLong(40.7127, -74.0059))
.mapType(MapTypeIdEnum.ROADMAP)
.zoom(12);
map = mapView.createMap(options);
mapView.setKey("");
showMarker(40.748433, -73.985656, "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Disc_Plain_red.svg/32px-Disc_Plain_red.svg.png");
showMarker(40.713, -74.0135, "https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Disc_Plain_blue.svg/32px-Disc_Plain_blue.svg.png");
}

/**
* Adds a marker to the map.
*/
public void showMarker(double lat, double lng, String iconPath) {
MarkerOptions options = new MarkerOptions();
options
.icon(iconPath)
.position(new LatLong(lat, lng));
Marker marker = new Marker(options);
map.addMarker(marker);
}

这是我遇到的错误。我想我只是错过了一些东西..............................................................

Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: ReferenceError: Can't find variable: loadMapLibrary
at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:146)
at com.sun.webkit.WebPage.twkExecuteScript(Native Method)


Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: ReferenceError: Can't find variable: google
at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:146)
at com.sun.webkit.WebPage.twkExecuteScript(Native Method)
at com.sun.webkit.WebPage.executeScript(WebPage.java:1509)

最佳答案

我必须在 Controller 的初始化方法中设置键mapView.setKey("");,然后 map 加载没有错误。

关于java - gMapsFX netscape.javascript.JSException : ReferenceError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49081557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com