【问题标题】:Google GWT maps API V3 Java bindingGoogle GWT 映射 API V3 Java 绑定
【发布时间】:2016-01-29 19:09:41
【问题描述】:

我正在使用 Google GWT 地图 API V3 java binding 3.8.0 更新地图应用程序。它是由 ANT 使用下载的 3 岁的 gwt-maps.jar 构建的。当前代码在旧 jar (3.8.0) 上运行良好:

import com.google.maps.gwt.client.MapOptions;
import com.google.maps.gwt.client.LatLng;
import com.google.maps.gwt.client.MapTypeId;
import com.google.maps.gwt.client.GoogleMap;
In GWT code take a button and write down the map loading code in to buttons onClick Event.

// This is the layout which will hold the button
final HLayout actionbuttonsLayout = new HLayout(10);
final IButton showMap = new IButton("Locate your Store");
actionbuttonsLayout.addMember(showMap);

//--- This is the layout which will hold the Map 
final HLayout mapLayout = new HLayout(50);  
final SimplePanel widg = new SimplePanel() ;
widg.setSize("700px", "200px");     
layout.addMember(mapLayout);
mapLayout.setVisible(false);

// This is the Click Handler where the map rendering process has been written
showMap.addClickHandler(new ClickHandler() {  

    public void onClick(ClickEvent event) {

        MapOptions options  = MapOptions.create();

        options.setCenter(LatLng.create(39.509, -98.434)); 
        options.setZoom(6);
        options.setMapTypeId(MapTypeId.ROADMAP);
        options.setDraggable(true);
        options.setMapTypeControl(true);
        options.setScaleControl(true);
        options.setScrollwheel(true);

        GoogleMap theMap = GoogleMap.create(widg.getElement(), options) ;
        mapLayout.addMember(widg);
        mapLayout.setVisible(true);
    }  
});

但如果我根据https://github.com/branflake2267/GWT-Maps-V3-Api/ 上的 branflake2267 指令将其更新为 Maven 存储库中可用的 API java 绑定的 3.9.0 或 3.10.0 版本)

<!-- GWT Maps API V3 -->
<dependency>
    <groupId>com.github.branflake2267</groupId>
    <artifactId>gwt-maps-api</artifactId>
    <version>3.10.0-alpha-7</version>
</dependency>

2. Add the inherits statement to your module.gwt.xml.   
```xml
<inherits name='com.google.gwt.maps.Maps' />

上面的代码不再起作用了!! Maven 构建找不到符号:GoogleMap、Marker、InfoWindow .... GoogleMap 类似乎不再在库中 - 是什么替换它? Marker 和 InfoWindow 类已在 3.9.0 中移至其他包。等等... 任何地方都没有支持更新的教程或示例。谁能告诉我将我的代码更新到 3.9.0 或 3.10.0 需要什么?非常感谢!

【问题讨论】:

    标签: api gwt google-maps-api-3 maps


    【解决方案1】:

    GoogleMap 已替换为 com.google.gwt.maps.client.MapWidget

    创建新地图的示例是:

    MapWidget.newInstance(MapImpl.newInstance(panel.getElement(), mapOptions));
    

    【讨论】:

    • 感谢您的提示!几个问题:1) "new MapWidget(mapOptions)" vs "MapWidget.newInstance(MapImpl.newInstance(panel.getElement(), mapOptions))"?
    • 感谢您的提示!我需要在代码中进行其他更新:LatLng、Marker 类和 InfoWindow 类已移至 com.google.gwt.maps.client.overlays 并且它们的 setMap() 现在采用 MapWidget 而不是 GoogleMap,对吗?我还需要注意哪些其他重大变化?
    • @Alex 我看到的两者之间的唯一区别是第二个自动将其附加到面板上。我不知道您可能需要进行哪些其他更改。我只是一步一步地走,直到它再次起作用。文档很糟糕,所以反复试验......
    • @Alex 如果您觉得我的回答解决了您的问题,请考虑accepting。这也适用于您之前的问题,因为您尚未接受任何答案。
    猜你喜欢
    • 1970-01-01
    • 2012-03-14
    • 1970-01-01
    • 2015-06-10
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多