I just wrote the code below. I am wondering why I did not have to call
InvokeOnMainThread when I added my map view annotation point(s). Seems like
the geocode complete handler would be on a background thread when it completes.
Is this blind luck that it runs, only runs in the emulator, or does this need
a InvokeOnMainThread so that it hits the ui thread?
void HandleSearchWhereSearchButtonClicked (object sender,
EventArgs e)
{
string sw = searchWhere.Text;
CLGeocoder clg = new CLGeocoder();
clg.GeocodeAddress(sw,
HandleHandleCLGeocodeCompletionHandlercompletionHandler);
}
void HandleHandleCLGeocodeCompletionHandlercompletionHandler
(CLPlacemark[] placemarks, NSError error)
{
int i = 0;
if ( oal.Count > 0 )
{
MapIt.RemoveAnnotations(oal.ToArray());
}
oal.Clear();
for(i = 0; i < placemarks.Length; i++)
{
var loc = placemarks[i].Location.Coordinate;
oal.Add(new ObjAnnotation(new
CLLocationCoordinate2D(loc.Latitude, loc.Longitude),
placemarks[i].Name, string.Empty));
}
MapIt.AddAnnotationObjects(oal.ToArray());
}
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch