From: Piotr T. <pi...@cg...> - 2010-12-08 18:49:33
|
Hello, I recently changed QxWT to SmartGWT and started to play with it. Unfortunately there is pretty big problem with rescaling OL-GWT widget in SmartGWT layout's. Problem seems to be nothing really new as some people are complain about that on SmartGWT's forum (unfortunately it seems to be ignored). Some code snippets: public class OLMapWidget extends Layout { final public MapWidget mapWidget; final MapOptions mapOptions; final WMSParams mapWMSParams; public OLMapWidget() { mapWMSParams = new WMSParams(); mapOptions = new MapOptions(); mapOptions.setNumZoomLevels(16); mapOptions.setProjection("EPSG:4326"); mapWidget = new MapWidget("1600", "1080", mapOptions); mapWMSParams.setFormat("image/png"); mapWMSParams.setLayers("basic"); mapWMSParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); WMS wmsLayer; wmsLayer = new WMS( "Basic WMS", "http://labs.metacarta.com/wms/vmap0", mapWMSParams, wmsLayerParams); mapWidget.getMap().addLayers(new Layer[] {wmsLayer}); mapWidget.getMap().setCenter(new LonLat(0, 0), 5); setWidth100(); setHeight100(); setAlign(Alignment.CENTER); setOverflow(Overflow.HIDDEN); setShowResizeBar(true); this.addChild(mapWidget); Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { /* String mapHeight = getParentElement().getHeightAsString(); String mapWidth = getParentElement().getWidthAsString(); mapWidget.setHeight(mapHeight); mapWidget.setWidth(mapWidth); */ mapWidget.setHeight(getHeightAsString()); mapWidget.setWidth(getWidthAsString()); mapWidget.getMap().updateSize(); } }); this.addResizedHandler( new ResizedHandler() { public void onResized( ResizedEvent event ) { //mapWidget.setHeight(Integer.toString(getInnerHeight())); //mapWidget.setWidth(Integer.toString(getInnerWidth())); mapWidget.setWidth(getWidthAsString()); mapWidget.setHeight(getHeightAsString()); mapWidget.getMap().updateSize(); } } ) ; } } public class Application implements EntryPoint { public void onModuleLoad() { VLayout mainLayout = new VLayout(); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.addMember(ViewHelper.createToolBar()); HLayout layout1 = new HLayout(); layout1.setWidth100(); layout1.addMember(ViewHelper.createLayerPanel()); final VLayout layout2 = new VLayout(); layout2.setHeight100(); layout2.setOverflow(Overflow.HIDDEN); layout2.addMember (new OLMapWidget()); layout2.addMember(ViewHelper.createTablePanel()); layout1.addMember(layout2); mainLayout.addMember(layout1); // mainLayout.addMember(ViewHelper.createStatusBar()); mainLayout.draw(); } } All is working ok unless browser windows is started as small and then expanded to bigger size - in that case OL-GWT widget size is always the same small. I guess its SmartGWT problem and the easiest way is saying bye bye to SmartGWT but maybe someone have some hack to override this problem (I know I can use ugly hack to manually change size of DIV but that doesnt look like good solution). /Peter |