gwtgoogle-maps-api-3google-eclipse-plugin

Example "Google Maps API v3 for GWT" Project for Eclipse


Google released official maps v3 API for GWT here https://groups.google.com/forum/#!topic/gwt-google-apis/6SO5kCDqb-k (Note that http://code.google.com/p/gwt-google-maps-v3/ is deprecated and is not official.)

I have downloaded the zip file and there are samples in it but they are all java. I can not figure out how to inherit it in my project.gwt.xml or what to write into my main html or where to put the gwt-maps.jar file.

Is there any complete Eclipse GWT project "for the OFFICIAL API" to start with? Or any guidance link which explains how to start from zero to my first class which has the OnModuleLoad()?

Thanks


Solution

  • Here are a few tips to help you get starting:

    gwt-maps.jar should be placed in WEB-INF/lib

    in your prject.gwt.xml you might add in your <module> section:

    <inherits name="com.google.maps.gwt.GoogleMaps" />
    <script src="http://maps.google.com/maps/api/js?sensor=false" />
    

    this will make loading maps api when loading page.

    Followings are copy/paste lines from my app, arrange them to match your needs:

            MapOptions options  = MapOptions.create() ;
    
        options.setCenter(LatLng.create( latCenter, lngCenter ));   
        options.setZoom( 6 ) ;
        options.setMapTypeId( MapTypeId.ROADMAP );
        options.setDraggable(true);
        options.setMapTypeControl(true);
        options.setScaleControl(true) ;
        options.setScrollwheel(true) ;
    
        SimplePanel widg = new SimplePanel() ;
    
        widg.setSize("100%","100%");
    
        GoogleMap theMap = GoogleMap.create( widg.getElement(), options ) ;
    
        RootLayoutPanel.get().add( widg ) ;
    

    This will build a widget with a map inside.