Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Using GoogleMaps 3.8.0 in SmartGWT app

    Hi
    I'm using SmartGWT 3.0p and try to load Google Maps inside HLayout container. The code is prity simple:

    static HLayout layout = new HLayout();

    public void onModuleLoad() {

    AjaxLoaderOptions options = AjaxLoaderOptions.newInstance();
    options.setOtherParms("sensor=false&language=ja");
    Runnable callback = new Runnable() {
    public void run() {
    renderMap();
    }
    };

    layout.setHeight100();
    layout.setWidth100();
    layout.draw();
    AjaxLoader.loadApi("maps", "3", callback, options);
    }

    public static void renderMap() {
    LatLng myLatLng = LatLng.create(-34.397, 150.644);
    MapOptions myOptions = MapOptions.create();
    myOptions.setZoom(8.0);
    myOptions.setCenter(myLatLng);
    myOptions.setMapTypeId(MapTypeId.ROADMAP);

    GoogleMap.create(layout.getElement(), myOptions);
    }


    and this doesn't work - the map is not shown on the browser. The same code but using pure GWT panels is working fine:

    //static HLayout layout = new HLayout();
    static LayoutPanel layout = new LayoutPanel();

    public void onModuleLoad() {

    AjaxLoaderOptions options = AjaxLoaderOptions.newInstance();
    options.setOtherParms("sensor=false&language=ja");
    Runnable callback = new Runnable() {
    public void run() {
    renderMap();
    }
    };

    // layout.setHeight100();
    // layout.setWidth100();
    layout.setHeight("100%");
    layout.setWidth("100%");
    // layout.draw();
    RootPanel.get().add(layout);
    AjaxLoader.loadApi("maps", "3", callback, options);
    }

    public static void renderMap() {
    LatLng myLatLng = LatLng.create(-34.397, 150.644);
    MapOptions myOptions = MapOptions.create();
    myOptions.setZoom(8.0);
    myOptions.setCenter(myLatLng);
    myOptions.setMapTypeId(MapTypeId.ROADMAP);

    GoogleMap.create(layout.getElement(), myOptions);
    }


    Is there any solution on this?
    Last edited by nevega; 19 Sep 2012, 06:25.

    #2
    Any luck?
    This is quiet a big issue considering that on May maps 2 will be no longer an option (https://developers.google.com/maps/documentation/javascript/v2/).

    Comment


      #3
      I'm having exactly the same issue.
      Would appreciate help.

      Thanks!

      Comment


        #4
        Actually, it appears to be working when using layout.getDOM() instead of layout.getElement()

        Comment

        Working...
        X