1

I'm using GWT (version 2.7.0) and gwt-maps (version 3.10.0-alpha-7) in an effort to display a Google Map via GWT.

I tried following code for map implementation but not able to show map widget :-

Geolocation location = Geolocation.getIfSupported();
location.getCurrentPosition(new Callback<Position, PositionError>() {

    @Override
    public void onSuccess(Position result) {
        try {
            latitude = result.getCoordinates().getLatitude();
            longitude = result.getCoordinates().getLongitude();
            MapOptions options = MapOptions.newInstance();

            options.setDraggable(true);
            options.setMapTypeControl(true);
            options.setScaleControl(true);

            map = MapWidget.newInstance(MapImpl.newInstance(mapHPanel.getElement(), options));
            map.setCenter(LatLng.newInstance(latitude, longitude));
            map.setZoom(6);
            map.setMapTypeId(MapTypeId.SATELLITE);
            map.setSize("500PX", "500px");

        } catch (Exception e) {

    } 
}

Which one would you guys suggest? Does somebody maybe had a similar problem and a solution for this? How can I get the Google Maps V3 API working in my GWT project?

Thank you very much guys for any help on this!

ParkerHalo
  • 4,341
  • 9
  • 29
  • 51

1 Answers1

2

I know this is an old question, but just in case anyone comes by from a search engine.

You need an api key, which you should give to the load funcion like

LoadApi.go(onLoad, loadLibraries,true,"key=GET_YOUR_GOOGLE_KEY_AND_INSERT_IT_HERE");

Also please don't shallow exceptions. If you had printed the exception instead of ignoring it, you would have seen the error message telling you that you need a key.

MTilsted
  • 5,425
  • 9
  • 44
  • 76