gpt4 book ai didi

java - 设置中心 : not a LatLng or LatLngLiteral: in property lat: not a number

转载 作者:行者123 更新时间:2023-12-03 11:06:29 25 4
gpt4 key购买 nike

我尝试使用 GWT Maps API V3 3.8.1 创建一个演示。我的演示只是显示了 API 版本 3 的谷歌地图

public class MyGoogleMap implements IsWidget {

private MapWidget map;

private static Boolean loadingApi = false;
private Timer apiLoadWaitTimer = null;
private LatLng CENTER = LatLng.newInstance(47.8, -121.4);

public MyGoogleMap(EventBus bus, String mapApiKey) {
this.eventBus = bus;
boolean sensor = true;
map = new MapWidget(MapOptions.newInstance());
// load all the libs for use in the maps
ArrayList<LoadLibrary> loadLibraries = new ArrayList<LoadApi.LoadLibrary>();
loadLibraries.add(LoadLibrary.ADSENSE);
loadLibraries.add(LoadLibrary.DRAWING);
loadLibraries.add(LoadLibrary.GEOMETRY);
loadLibraries.add(LoadLibrary.PANORAMIO);
loadLibraries.add(LoadLibrary.PLACES);
loadLibraries.add(LoadLibrary.WEATHER);

final AjaxLoaderOptions options = AjaxLoaderOptions.newInstance();

Runnable callback = new Runnable() {
@Override
public void run() {
initMap();
mapMenuProvider = new DefaultMapMenuProvider();
mapController = new MapController(map);
mapController.setMenuProvider(mapMenuProvider);
}
};
LoadApi.go(callback, loadLibraries, sensor);
}

private void initMap() {
MapOptions mapOptions = MapOptions.newInstance();
map = new MapWidget(mapOptions);
map.setCenter(CENTER);
}
}

我的 .gwt.xml 包含:

<inherits name='com.google.gwt.maps.Apis_Google_Maps' />
<!-- <inherits name='com.google.gwt.maps.utility.GoogleMapsUtility' /> -->
<script src="https://maps.googleapis.com/maps/api/jsv=3&amp;key=MyGoogleAPIKey####&amp;sensor=false"/>

我的演示成功显示了 Google map 。但是,语句 map.setCenter(CENTER) 会产生以下错误

setCenter: not a LatLng  or LatLngLiteral: in property lat: not a number 

什么原因导致此错误消息?

最佳答案

我解决了这个问题。错误出在 initMap() 方法中。我更正如下:

 private void initMap() {
mapWidget.setSize("100%", "100%");
mapWidget.setZoom(zoomLevel);
mapWidget.setCenter(CENTER);
}

关于java - 设置中心 : not a LatLng or LatLngLiteral: in property lat: not a number,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27836161/

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