Hello. My problem: I have a Google MapWidget. That i have in a Hlayout. I want to resize it when browser changes size. But, i can only make it expand and collapse from the initial width/height. If becomes larger, the layout&map expands, if it then shrinks it shrinks until it has the initial size upon page load, then it stays that way.
If i don't add the mapwidget as a child in the layout, it expands and shrinks as expected. But if i add the mapwidget, i stop getting resize calls whenever the layout becomes smaller than initial.
(as you can see i'm calling addChild, but i couldn't see any difference with addMember)
I am hoping that someone has an idea as to how i can fix this. My class below:
If i don't add the mapwidget as a child in the layout, it expands and shrinks as expected. But if i add the mapwidget, i stop getting resize calls whenever the layout becomes smaller than initial.
(as you can see i'm calling addChild, but i couldn't see any difference with addMember)
I am hoping that someone has an idea as to how i can fix this. My class below:
Code:
public class MapLayout extends HLayout {
protected MapWidget map;
........
public MapLayout(final String mapId, String circleFillColour, double circleOpacity, MapOptions options) {
setID(mapId);
//we want to make sure that the map always takes up the entire layout, since it doesn't scale automatically.
addResizedHandler(e -> {
map.setPixelSize(getWidth(), getHeight());
map.triggerResize();
});
//i have tried lots of different variants here, which hasn't made it work.
setMinWidth(50);
setMinHeight(50);
setWidth100();
setHeight100();
setBorder("3px solid blue");
setMargin(0);
setPadding(0);
setMembersMargin(0);
this.circleFillColour = circleFillColour;
this.circleOpacity = circleOpacity;
map = createMap((options != null ? options : MapConstants.getDefaultOptions()));
map.setWidth("100%");
map.setHeight("100%");
setCenter(MapConstants.DEFAULT_LAT, MapConstants.DEFAULT_LON);
addChild(map);
}
Comment