[android-developers] Re: Is MapController's zoomToSpan() execution deferred?

2010-09-01 Thread Chad McQuillen
That sounded like an excellent suggestion so I gave it a try.  The new
code looks like this:

mapController.zoomToSpan(latitudeDelta, longitudeDelta);
/*
 * If the MapView has not been drawn yet, we won't be able to retrieve
an
 * accurate zoom level.  We have to queue up the work to make the
adjustment,
 * if necessary.
 */
mapView.post(new Runnable() {
public void run() {
if (mapView.getZoomLevel() > 20) {
mapView.getController().setZoom(20);
}
}
});

And, that still didn't work although I fully expected it to.  But,
after debugging it awhile I noticed some strange behavior that I did
not expect.  First, I wanted to check that my runnable got queued up
OK, and it ran when I expected it to run.  It did not.  Before I
explain what I observed let me first explain my activity / view
structure.

Tabbed Activity w/ 3 tabs
   - Tab 1 - ListActivity
   - Tab 2 - MapActivity
   - Tab 3 - Plain 'Ol Activity

So the sequence I did was:

1.  Enter Tabbed Activity, ListActivity in Tab 1 is shown by default.
2.  Click on Tab2, the MapActivity.

I would have expected the Runnable to be executed at this point.

3.  Click 'back' to exit Tabbed Activity.
4.  Re-enter Tabbed Activity, again ListActivity in Tab 1 is shown by
default.

And, this is the point at which the Runnable was executed.  I am at a
loss as to why.

P.S.  I must have misunderstood getMaxZoomLevel() because that didn't
return what I thought it would which is the zoom level at which you
still get the satellite imagery and not the blank white screen w/ grey
X's.  So, I went back and hard-coded to zoom level 20.


On Sep 1, 4:29 pm, Steve Howard  wrote:
> The zoom may be deferred if the MapView hasn't been drawn yet.  Have you
> tried putting your logic in a Runnable and post()ing it to the MapView?
>
> Steve
>
> On Sun, Aug 29, 2010 at 7:18 PM, Chad McQuillen 
> wrote:
>
>
>
> > My application has a MapView which shows a collection of items in a
> > satellite view.  I use the MapController's zoomToSpan() method to
> > initialize the zoom level of MapView.  I later discovered that the
> > MapView was showing a blank white screen with grey X's (zoom'd too
> > far, zoom out once and everything looks as expected) for the use case
> > when the collection of item's locations were very close to each
> > other.  So, I modified the code from this:
>
> > mapController.zoomToSpan(latitudeDelta, longitudeDelta);
>
> > to this:
>
> > mapController.zoomToSpan(latitudeDelta, longitudeDelta);
>
> > if (mapView.getZoomLevel() > mapView.getMaxZoomLevel()) {
> >        mapController.setZoom(mapView.getMaxZoomLevel());
> > }
>
> > but, I still got the same result.  I added some debug before and after
> > the zoomToSpan() to retrieve the zoom level from MapView and noticed
> > that the zoom level did not change.  I'm guessing somehow that the
> > work is queued up??
>
> > I don't know if this information is important or not to this problem,
> > but I'll also mention that the MapView is created from a MapActivity
> > which is hosted in the tab host of a TabActivity that contains three
> > tabs, one of which is the map.  I searched this forum and elsewhere
> > and haven't seen anyone encounter such a problem before.  I'm hoping
> > someone can point me in the right direction.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

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


[android-developers] Is MapController's zoomToSpan() execution deferred?

2010-09-01 Thread Chad McQuillen
My application has a MapView which shows a collection of items in a
satellite view.  I use the MapController's zoomToSpan() method to
initialize the zoom level of MapView.  I later discovered that the
MapView was showing a blank white screen with grey X's (zoom'd too
far, zoom out once and everything looks as expected) for the use case
when the collection of item's locations were very close to each
other.  So, I modified the code from this:

mapController.zoomToSpan(latitudeDelta, longitudeDelta);

to this:

mapController.zoomToSpan(latitudeDelta, longitudeDelta);

if (mapView.getZoomLevel() > mapView.getMaxZoomLevel()) {
mapController.setZoom(mapView.getMaxZoomLevel());
}

but, I still got the same result.  I added some debug before and after
the zoomToSpan() to retrieve the zoom level from MapView and noticed
that the zoom level did not change.  I'm guessing somehow that the
work is queued up??

I don't know if this information is important or not to this problem,
but I'll also mention that the MapView is created from a MapActivity
which is hosted in the tab host of a TabActivity that contains three
tabs, one of which is the map.  I searched this forum and elsewhere
and haven't seen anyone encounter such a problem before.  I'm hoping
someone can point me in the right direction.

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