My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DemoGwtMaps  
Demo GWT Maps api
Updated Oct 11, 2011 by branflak...@gmail.com

Notes On Version 3 Api

Maps V3 api needs outside help due to limited resources currently on other projects at the moment. I am suggesting automating the javascript implementation build process to help us not fall behind on future javascript api version. (Automating is the GWT APIs team idea, Thanks Eric)

Demo GWT Maps

The goal is to render or a map with GWT.
  • Demo - Simple Maps Demo
  • Source - find the source here
  • c.Gawkat.com - I use gwt maps api here for my panoramic virtual tours.

Custom Map Controls

Want to add your own control to the map.
    ControlPosition controlPosition = new ControlPosition(ControlAnchor.TOP_LEFT, 100, 0);
    Control handControl = new Control.CustomControl(controlPosition) {
      public boolean isSelectable() {
        return true;
      }
      protected Widget initialize(MapWidget map) {
        Image mhand = new Image(UI_IMAGES.map_hand());
        mhand.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {
            // do something
          }
        });
        return mhand;
      }
    };
    map.addControl(handControl);
Method example
private void drawMapAddItems() {
    final Image mhand = new Image(UI_IMAGES.map_hand());
    final Image mhandsel = new Image(UI_IMAGES.map_hand_sel());
    
    final Image mpush = new Image(UI_IMAGES.map_add_pushpin());
    final Image mpushsel = new Image(UI_IMAGES.map_add_pushpin_sel());
    
    
    ControlPosition controlPosition = new ControlPosition(ControlAnchor.TOP_LEFT, 100, 0);
    Control handControl = new Control.CustomControl(controlPosition) {
      public boolean isSelectable() {
        return true;
      }
      public Widget initialize(MapWidget map) {  
        return mhand;
      }
    };
    map.addControl(handControl);
    
    ControlPosition controlPosition2 = new ControlPosition(ControlAnchor.TOP_LEFT, 100, 0);
    Control handControl2 = new Control.CustomControl(controlPosition2) {
      public boolean isSelectable() {
        return true;
      }
      public Widget initialize(MapWidget map) {  
        return mhandsel;
      }
    };
    map.addControl(handControl2);
    
    mhand.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        mhand.setVisible(false);
        mhandsel.setVisible(true);
      }
    });
    
    mhandsel.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        mhand.setVisible(true);
        mhandsel.setVisible(false);
      }
    });
    
    mhandsel.setVisible(true);
    mhand.setVisible(false);
  }


Sign in to add a comment
Powered by Google Project Hosting