簡體   English   中英

Google GWT Maps API V3 Java綁定

[英]Google GWT maps API V3 Java binding

我正在使用Google GWT Maps 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);
    }  
});

但是,如果我將其更新為Maven存儲庫中可用的API Java綁定的3.9.0或3.10.0版本,請按照https://github.com/branflake2267/GWT-Maps-V3-Api/上的branflake2267說明進行操作)

<!-- 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會如何嗎? 非常感激!!

GoogleMap已被com.google.gwt.maps.client.MapWidget取代。

創建新地圖的示例是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM