Thursday, December 17, 2009

Re: New layouts not playing nicely with Maps

Hi Jeff,

I played around with this and got it to work with these panels:

private MapWidget map;

// GWT module entry point method.
public void onModuleLoad() {
Maps.loadMapsApi(null, null, false, new Runnable() {
public void run() {
LatLng cawkerCity = LatLng.newInstance(39.509, -98.434);
// Open a map centered on Cawker City, KS USA

map = new MapWidget(cawkerCity, 2);
map.setSize("100%", "100%");
map.setUIToDefault();

DockLayoutPanel dock = new DockLayoutPanel(Unit.PX);
dock.setHeight("600px");
dock.setWidth("400px");
SplitLayoutPanel split = new SplitLayoutPanel();
dock.add(split);
split.addNorth(map, 500);
split.setWidth("100%");
split.setHeight("100%");
// Add the map to the HTML host page
RootPanel.get().add(dock);
new Timer() {
public void run() {
map.checkResizeAndCenter();
}
}.schedule(1);
}
});
}


On Sat, Dec 12, 2009 at 3:51 AM, Jeff Schnitzer <jeff@infohazard.org> wrote:
Does anyone have the GWT Google maps working inside the new Layout
panels?

My page is basically a DockLayoutPanel whose main element is a
SplitLayoutPanel whose main element is a MapWidget.  The MapWidget is
set to 100% size.

On startup, the map tiles are sized to a very small part of the area,
although the grey background does seem to cover the entire space:

http://www.infohazard.org/~jeff/mapnolayout.png

If I resize the browser window, the map quickly covers the whole area
and starts to work normally.

I've tried calling MapWidget.checkResize() and the LayoutPanel's
forceLayout() methods but neither have an effect.  Any idea what I'm
doing wrong?

The code is super-simple:

       SplitLayoutPanel split = new SplitLayoutPanel();
       this.add(split);  // to the DockLayoutPanel

       split.addWest(new HTML("<p>blah</p>"), 200);

       LatLng cawkerCity = LatLng.newInstance(39.509, -98.434);
       MapWidget map = new MapWidget(cawkerCity, 4);
       map.setSize("100%", "100%");
       split.add(map);

Thanks,
Jeff

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.





--
Eric Z. Ayers
Google Web Toolkit, Atlanta, GA USA

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate