ZAJ
ZAJ

Reputation: 835

Error in running GWT Map - Is the Maps key missing or invalid?

I am trying to integrate the gwt map into my SmartGWT app. But for some reason I am getting this error. Can somebody please help me to resolve it. I am using this link as my reference http://forums.smartclient.com/showthread.php?t=3366.

the error i get is Uncaught exception escaped : java.lang.RuntimeException The Maps API has not been loaded. Is a tag missing from your host HTML or module file? Is the Maps key missing or invalid? See the Development console log for details. Register a GWT.setUncaughtExceptionHandler(..) for custom uncaught exception handling.

//This is added in my module file and i am using Maps v2 API 1.1.1 
<inherits name='com.google.gwt.maps.GoogleMaps' />


   HomeViewImpl homePanel = new HomeViewImpl();
   addTab(homePanel, "Home", "Home");

==============================================

public class HomeViewImpl extends VLayout
{

private MapWidget getMap()
{
    /*MapWidget map = new MapWidget();
    map.setSize("500px", "300px");
    map.addControl(new LargeMapControl());
    map.getInfoWindow().open(map.getCenter(), new InfoWindowContent(getMapInfoWindow()));
    return map;*/
    LatLng cawkerCity = LatLng.newInstance(-22.82, -47.26);
    final MapWidget map = new MapWidget();
    map.setScrollWheelZoomEnabled(true);

    map.addControl(new LargeMapControl());

    map.addOverlay(new Marker(cawkerCity));

    map.getInfoWindow().open(map.getCenter(),
        new InfoWindowContent("World's Largest Ball of Sisal Twine"));

    return map;
}

public Canvas getViewPanel()
{
    HLayout hLayout = new HLayout(5);
    hLayout.addMember(new Label("Dummy Label in a Horizontal Layout"));
    // Add the map to the HTML host page
    hLayout.addMember(getMap());
    return hLayout;
}

private Canvas getMapInfoWindow()
{
    final TabSet topTabSet = new TabSet();
    topTabSet.setTabBarPosition(Side.TOP);
    topTabSet.setWidth(200);
    topTabSet.setHeight(100);

    Tab tTab1 = new Tab("Blue");

    HTMLPane tab1Pane = new HTMLPane();
    tab1Pane.setContents("Hello. This sample shows a google map widget taking part in a SmartGWT Layout");
    tTab1.setPane(tab1Pane);
    Tab tTab2 = new Tab("Green");
    HTMLPane tab2Pane = new HTMLPane();
    tab2Pane.setContents("Google Maps InfoWindow can display SmartGWT Widgets");
    tTab2.setPane(tab2Pane);

    topTabSet.addTab(tTab1);
    topTabSet.addTab(tTab2);
    return topTabSet;
}

@Override
public Widget asWidget()
{
    return getViewPanel();
}

}

cheers Zolf

Upvotes: 0

Views: 517

Answers (3)

ZAJ
ZAJ

Reputation: 835

Ok the problem with my case was that I had to also add this scropt to my module file.Adding this resolved the error and displayed the Map.

 <script src="http://maps.google.com/maps?gwt=1&amp;file=api&amp;v=2"></script>

Upvotes: 0

Prasanth Np
Prasanth Np

Reputation: 175

You have to create map and load data like this,

Maps.loadMapsApi("", "2", false, new Runnable() {
  public void run() {
   // add your widget with map
  }
});

see this link for example: http://code.google.com/p/gwt-google-apis/wiki/MapsGettingStarted & download and use the jar which is used in this example.

Upvotes: 0

Thomas Newman
Thomas Newman

Reputation: 194

There are a few things happening here.

Google Maps v2 is no longer available. Please read Upgrading Your Google Maps JavaScript Application To v3. The link you provide is from 2008 and is well and truly out of date.

Second, Google Maps (either v2 or v3) require a valid license key in the host HTML page. GWT has a host HTML page that launches the GWT application. The Google Maps key can go here.

You will also require an updated GWT Google maps API to make use of Maps v3. There are a few available.

Regards, Thomas.

Upvotes: 1

Related Questions