Google GWT映射API V3 Java绑定

时间:2015-10-29 14:59:01

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

我正在使用Google GWT地图API V3 java绑定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类不再在库中了 - 它取代了什么?标记和InfoWindow类已移至3.9.0中的其他包。等...没有任何教程或样本可以支持更新。任何人都可以让我知道如何将我的代码更新到3.9.0或3.10.0?非常感谢!!

1 个答案:

答案 0 :(得分:0)

[HttpGet] public ActionResult Index() { ViewBag.noofsitesvisited = "No of times site visited=" + HttpContext.Application["SiteVisitedCounter"].ToString(); ViewBag.onlineusers = "No of users online on the site=" + HttpContext.Application["OnlineUserCounter"].ToString(); } 已替换为GoogleMap

创建新地图的示例如下:

com.google.gwt.maps.client.MapWidget