Announcement

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

    Smart GWT and OpenLayers

    Hi,

    In my project I'm using Smart GWT and GWT OpenLayers (http://gwt-openlayers.sourceforge.net/). GWT OpenLayers has a GWT widget called MapWidget which contains a map.

    I'm trying to put my map into a VLayout and have it fill up all available space. However, when I run my application the MapWidget always has a height of 0px. The code I'm using to add my MapWidget is as follows:

    VLayout mapLayout = new VLayout();
    mapLayout.setWidth100();
    mapLayout.setHeight100();
    mapLayout.setBackgroundColor("#FFFF99");

    mapWidget = createMap();
    mapLayout.addMember(mapWidget);

    When I create my MapWidget, I try to make its size 100% by calling the widgets setWidth and setHeight methods. This all happens in createMap(). When I use the same createMap() method in a pure GWT application it works fine, so I don't think there's an issue there. I'm pretty sure the problem is with Smart GWT.

    Has anybody has a similar problem before? Does anybody know how I might solve this?

    Thanks!

    Jon

    #2
    Yes. I'm can not find normal solution for this problem. But hot fixs is create wrapped layout with size 100%.

    Comment


      #3
      Thanks for the reply. What do you mean by "create wrapped layout with size 100%"? I'm already putting my MapWidget inside a VLayout.

      Jon

      Comment


        #4
        You can do something like:
        Code:
        MapWidget mapWidget = ...;
        VLayout mapCanvas;
        public void init(){
        	mapCanvas = new VLayout ();
        	mapCanvas.setWidth100();
        	mapCanvas.setHeight100();
        
        	mapCanvas.addResizedHandler(new ResizedHandler() {
        		@Override
        		public void onResized(ResizedEvent event) {
        			resizeMapWidget();
        		}
        	});
        	mapCanvas.addChild(mapWidget);
        }
        
        public void resizeMapWidget(){
        	mapWidget.setHeight(String.valueOf(mapCanvas.getHeight())+"px");
        	mapWidget.setWidth(String.valueOf(mapCanvas.getWidth())+"px");		
        }

        Comment


          #5
          Do you have problems with automatic (no configuration) events managed by openlayers as pan, zoom, rectangle zoom?

          Comment


            #6
            Hi,
            I'm facing quite the same problem:
            Opening a SmartGWT modal window within an openlayers mapping application works ok - but after closing that window, navigation in the mapping application is not possible anymore.
            Does anyone know how to give back control (event handling) back to the calling application??

            Greets, Andreas

            Versions: SmartGWT 2.4 FF4

            Comment


              #7
              Thanks a lot, this works fine!
              Originally posted by dencel View Post
              You can do something like:
              Code:
              MapWidget mapWidget = ...;
              VLayout mapCanvas;
              public void init(){
              	mapCanvas = new VLayout ();
              	mapCanvas.setWidth100();
              	mapCanvas.setHeight100();
              
              	mapCanvas.addResizedHandler(new ResizedHandler() {
              		@Override
              		public void onResized(ResizedEvent event) {
              			resizeMapWidget();
              		}
              	});
              	mapCanvas.addChild(mapWidget);
              }
              
              public void resizeMapWidget(){
              	mapWidget.setHeight(String.valueOf(mapCanvas.getHeight())+"px");
              	mapWidget.setWidth(String.valueOf(mapCanvas.getWidth())+"px");		
              }

              Comment

              Working...
              X