0

I am working on updating a map application using Google GWT maps API V3 java binding 3.8.0. It is built by ANT using a downloaded gwt-maps.jar 3 years old. The current code worked fine with the old 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);
    }  
});

But if I update it to 3.9.0 or 3.10.0 version of the API java binding available in Maven repository per branflake2267 instructions on https://github.com/branflake2267/GWT-Maps-V3-Api/)

<!-- 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' />

The above code no longer works!! Maven build cannot find symbols: GoogleMap, Marker, InfoWindow.... It appears GoogleMap class is no longer in the library - what is replacing it? Marker, and InfoWindow classes have been moved to other packages in 3.9.0. etc... There are no tutorials or samples anywhere to support the update. Can anyone please let me know what it takes to update my code to 3.9.0 or 3.10.0?? Much appreciated!!

1 Answer 1

0

GoogleMap has been replaced by com.google.gwt.maps.client.MapWidget.

An example to create a new map is:

MapWidget.newInstance(MapImpl.newInstance(panel.getElement(), mapOptions));
4
  • Thanks for the tip! A couple of questions: 1) "new MapWidget(mapOptions)" vs "MapWidget.newInstance(MapImpl.newInstance(panel.getElement(), mapOptions))"?
    – Alex
    Oct 29, 2015 at 19:58
  • Thanks for the tip! Other updates I will need to make in the code: LatLng, Marker class and InfoWindow class are moved to com.google.gwt.maps.client.overlays and their setMap() now takes MapWidget instead of GoogleMap, correct? Any other major changes I need to be aware of?
    – Alex
    Oct 29, 2015 at 20:08
  • @Alex The only difference between the two that I see is that the second one attaches it to the panel automatically. I don't know what other changes your may need to make. I just went step by step until it worked again. The documentation is awful, so trial and error...
    – Baz
    Oct 29, 2015 at 20:13
  • @Alex If you feel that my answer solved your problem, please consider accepting. This also holds for your older questions as you haven't accepted any answer yet.
    – Baz
    Oct 30, 2015 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.