[mono-android] maps - I'm doing something wrong
Jonathan Pryor
jonp at xamarin.com
Wed Nov 9 20:54:45 EST 2011
On Nov 9, 2011, at 6:57 PM, Wally McClure wrote:
> I've got the code below. I have a "real" key determined from the machine that I am running on right now (I know because I just recreated it). The problem that I am running into is that the map_view is sometimes null and sometimes not. Has anyone else seen this behavior?
I'm betting it's a threading problem:
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MyLocationOverlay.html#runOnFirstFix(java.lang.Runnable)
"as soon as we get a location fix, we'll run it in in a new thread"
Which means this:
> location_overlay.RunOnFirstFix(delegate
> {
> map_view.Controller.AnimateTo(location_overlay.MyLocation);
> });
may invoke `map_view` from the wrong thread. Try changing it to:
location_overlay.RunOnFirstFix (delegate {
RunOnUiThread (() => map_view.Controller.AnimateTo(location_overlay.MyLocation));
});
- Jon
More information about the Monodroid
mailing list