setCenter:不是 LatLng 或 LatLngLiteral:在属性中 lat:不是数字

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

我尝试使用 GWT Maps API V3 3.8.1 创建演示。我的演示仅显示 google 地图与 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.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);
}