View Full Version : GXT GWT Panel Map Size Issue

28 Sep 2013, 7:03 AM
Hello, I'm using GWT 2.5.0 , GXT 2.2.5 and GWT Google Maps API v3 (https://github.com/branflake2267/GWT-Maps-V3-Api)
Initially, the map is displayed with the minimum size at the top left corner. My problem is similar to the one discussed here (http://code.google.com/p/gwt-google-apis/issues/detail?id=127):
Here is my code?

Any ideas on what I should do to make sure the map dispayed full size in the center of my layout. Thanks a lot.

// put the map into a panel.
MapOptions options = MapOptions.newInstance();

//center is a LatLgn and is a parameter to this method
ZoomControlOptions zco = ZoomControlOptions.newInstance();

map = new MapWidget(options);
// set size
map.setSize("100%", "100%");

// adding map to EXT JS Panel
final ContentPanel mapPanel = new ContentPanel();
mapPanel.setLayout(new FitLayout());
mapPanel.add(new WidgetComponent(map) {
* Ensure that the {@link MapWidget} knows its new size.
* {@inheritDoc}
protected void onResize(final int width, final int height) {
super.onResize(width, height);
((MapWidget) getWidget()).setPixelSize(width, height);
}, new FitData());

final BorderLayoutData layoutData = new BorderLayoutData(
layoutData.setMargins(new Margins(MARGIN_SIZE));

final ContentPanel panel = Registry.get(PANEL_CONSOLE_KEY);
panel.add(mapPanel, layoutData);

29 Sep 2013, 8:34 AM
The challenge is I need to add a handler to that api so it listens for layout change events. So to fix this, at the end of the animation cycle of a panel displaying or a layout change the mapWidget.triggerResize() needs to be called so that the tiles know that the size of the panel is larger than when it was instantiated with.

Try this on a layout change. (to experiment, a timer can be added to execute this to verify this is the cause)


Would you like to see how I might add a resize handler to trigger that?

29 Sep 2013, 10:02 AM
Thanks for your answer.

I override the onLoad method of the WidgetComponent to which the mapwidget was added. This seems to have solved my issue. Thank you very. Yes, I'm curious to see how you would add that :)

Also: i sent you an email to your gmail account. Any chance you could reply to the email when you have a mn?

protected void onLoad() {
((MapWidget) getWidget()).triggerResize();