I had this problem a few months ago
http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/c0dc9b54edd48531
and solved it with a callback which is more reliable than a timer
because it cancels any existing animation which might run past your
timeout.
root.animate(0, new AnimationCallback()
{
public void onLayout(Layer layer, double progress)
{
}
public void onAnimationComplete()
{
map.checkResizeAndCenter();
}
});
On Dec 22, 10:13 pm, Stuart <[email protected]> wrote:
> I am using UI binding to setup my app, so I needed a little extra
> tweak to Eric's code.
>
> If I placed the timer either before or after the createAndBindUi call
> in my widget containing the map, I was still experiencing the map UI
> rash Jeff and Andrew had.
>
> However, since my app also uses event handling (via gwt-dispatch), I
> was able to fire a custom RetrievedMap event at a place in the code
> when I know the app has completely finished UI binding (ie, the user
> clicks on a nav item to fetch map data, the app retrieves a success
> from the server, the app then fires the RetrievedMap event ). My
> docker widget containing the MapWidget listens for the RetrievedMap
> event, and so I tucked in Eric's timer code to the method handling the
> RetrievedMap event and it worked wonderfully.
>
> Phew. What I am trying to say is: if you are using UI binding, a plain
> Timer fix may not work because of arbitrary times that your UI may
> complete binding. Best to fire an event when you know the UI is
> completely loaded, and in handling the event run Eric's timer code.
>
> Stuart
>
> On Dec 21, 11:06 am, Andrew Winter <[email protected]> wrote:
>
>
>
> > Thanks, Eric. The timer thing does exactly what I wanted.
>
> > Andrew.
>
> > On Dec 21, 12:54 pm, Eric Ayers <[email protected]> wrote:
>
> > > On Mon, Dec 21, 2009 at 6:19 AM, Andrew Winter <[email protected]>
> > > wrote:
> > > > Hi,
>
> > > > I have the exact same problem as Jeff. One difference between Jeff's
> > > > case and Eric's case is that in Jeff's case, the dimensions of the map
> > > > are not known; in Eric's case the map is 400px by 500px. It seems this
> > > > problem occurs when the dimensions of the map are not known at build-
> > > > time.
>
> > > > I want my map to occupy the bottom-right corner of my UI (like Google
> > > >Maps). When I use setSize("100%,"100%"), theMapWidgetis given the
> > > > correct size (the Google logo etc appear in the right place) but the
> > > > tiles don't cover the whole of the widget.
>
> > > The trick I used to schedule checkResizeAndCenter() in a timer
> > > callback solved that issue for me
>
> > > > When I provide an explicit
> > > > size, or resize the browser, the tiles are displayed correctly.
>
> > > > I don't really want to provide dimensions in pixels if I don't have
> > > > to. Is this the only way?
>
> > > In the past I've always recommended dimensions in pixels for best
> > > results. You could hack around this by hooking into the resize event
> > > listener.
>
> > > > Thanks
>
> > > > Andrew.
>
> > > > On Dec 17, 6:44 pm, Eric Ayers <[email protected]> wrote:
> > > >> Hi Jeff,
>
> > > >> I played around with this and got it to work with these panels:
>
> > > >> privateMapWidgetmap;
>
> > > >> // 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 = newMapWidget(cawkerCity, 2);
> > > >> map.setSize("100%", "100%");
> > > >> map.setUIToDefault();
>
> > > >>DockLayoutPaneldock = newDockLayoutPanel(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 <[email protected]>
> > > >> wrote:
> > > >> > Does anyone have the GWT Googlemapsworking inside the new Layout
> > > >> > panels?
>
> > > >> > My page is basically aDockLayoutPanelwhose main element is a
> > > >> > SplitLayoutPanel whose main element is aMapWidget. TheMapWidgetis
> > > >> > 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 callingMapWidget.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 theDockLayoutPanel
>
> > > >> > split.addWest(new HTML("<p>blah</p>"), 200);
>
> > > >> > LatLng cawkerCity = LatLng.newInstance(39.509, -98.434);
> > > >> > MapWidgetmap = newMapWidget(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
> > > >> > [email protected].
> > > >> > To unsubscribe from this group, send email to
> > > >> > [email protected]<google-web-toolkit%2Bunsubs
> > > >> > [email protected]>
> > > >> > .
> > > >> > 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
> > > > [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected].
> > > > For more options, visit this group
> > > > athttp://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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.