public void execute() { getMap().updateSize(); } });
/** * Programmatically creates the element that will contain the map, * with the given width and height. * * The map itself is instantiated upon calling {@link #getMap()}. * * @param width - a String with the width of the element that will contain the map in CSS units. * @param height - a String with the height of the element that will contain the map in CSS units. * @param options - null if no options should be set upon map instantiation * or a MapOptions object that is passed to the map upon instantiation. * * @since GWT-OL 0.2 */ public MapWidget(String width, String height, MapOptions options) { Element e = DOM.createDiv(); this.options = options; setElement(e); setWidth(width); setHeight(height); }
/** * Gets the map associated with a MapWidget instance. * * The map is instantiated when this method is called for the first time. * * @return Map - see {@link Map}. */ public Map getMap() { //The preference here is lazy initalization if (map == null) { if (options == null) { map = new Map(getElement()); } else { map = new Map(getElement(), options); } } return map; }
/** * Gets the map associated with a MapWidget instance. * * The map is instantiated when this method is called for the first time. * * @return Map - see {@link Map}. */ public Map getMap() { //The preference here is lazy initalization if (map == null) { if (options == null) map = new Map(getElement()); else map = new Map(getElement(), options); } return map; }
/** * Programmatically creates the element that will contain the map, with the * given width and height. * * The map itself is instantiated upon calling {@link #getMap()}. * * @param width - a String with the width of the element that will contain * the map in CSS units. * @param height - a String with the height of the element that will contain * the map in CSS units. * @param options - null if no options should be set upon map instantiation * or a MapOptions object that is passed to the map upon instantiation. * * @since GWT-OL 0.2 */ public MapWidget(String width, String height, MapOptions options) { Element e = DOM.createDiv(); this.options = options; setElement(e); setWidth(width); setHeight(height); }
public void onResize() { getMap().updateSize(); } }
public void execute() { getMap().updateSize(); } });
public void onModuleLoad() { MapOptions mapOptions = new MapOptions(); MapWidget mapWidget = new MapWidget( "400px", "300px", mapOptions ); OSM osm_1 = OSM.Mapnik( "Mapnik" ); OSM osm_2 = OSM.CycleMap( "CycleMap" ); osm_1.setIsBaseLayer( true ); osm_2.setIsBaseLayer( true ); LonLat lonLat = new LonLat( 6.95, 50.94 ); lonLat.transform( "EPSG:4326", "EPSG:900913" ); Map map = mapWidget.getMap(); map.addLayer( osm_1 ); map.addLayer( osm_2 ); map.addControl( new LayerSwitcher() ); map.addControl( new MousePosition() ); map.setCenter( lonLat, 12 ); RootPanel.get().add( mapWidget ); }