Permalink
Browse files

Code cleanup in MapKitSearch

  • Loading branch information...
1 parent 31a258e commit a98c0b6caa3839d97c2671a21a6ff9115f2c2f65 @bopang bopang committed with pjbeaman Jul 23, 2013
Showing with 0 additions and 35 deletions.
  1. +0 −35 MapKitSearch/AppDelegate.cs
@@ -38,9 +38,6 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
lm.StartUpdatingLocation ();
}));
}
-// section.Add (new StringElement ("Search...", delegate {
-// Search (what.Value, where.Value);
-// }));
section.Add (new StringElement ("Search...", async delegate {
await SearchAsync (what.Value, where.Value);
@@ -68,38 +65,6 @@ CLLocationCoordinate2D Parse (string s)
return new CLLocationCoordinate2D ();
}
- void Search (string what, string where)
- {
- var coord = here == null ? Parse (where) : here.Coordinate;
-
- MKCoordinateSpan span = new MKCoordinateSpan (0.25, 0.25);
- MKLocalSearchRequest request = new MKLocalSearchRequest ();
- request.Region = new MKCoordinateRegion (coord, span);
- request.NaturalLanguageQuery = what;
-
- MKLocalSearch search = new MKLocalSearch (request);
-
- search.Start (delegate (MKLocalSearchResponse response, NSError error) {
- // this is executed in the application main thread
- if (response == null || error != null)
- return;
-
- var section = new Section ("Search Results for " + what);
- results.Clear ();
- foreach (MKMapItem mi in response.MapItems) {
- results.Add (mi);
- var element = new StyledStringElement (mi.Name, mi.PhoneNumber, UITableViewCellStyle.Subtitle);
- element.Accessory = UITableViewCellAccessory.DisclosureIndicator;
- element.Tapped += () => { results [element.IndexPath.Row].OpenInMaps (); };
- section.Add (element);
- }
-
- var root = new RootElement ("MapKit Search Sample") { section };
- var dvc = new DialogViewController (root);
- (window.RootViewController as UINavigationController).PushViewController (dvc, true);
- });
- }
-
async Task SearchAsync (string what, string where)
{
var coord = here == null ? Parse (where) : here.Coordinate;

0 comments on commit a98c0b6

Please sign in to comment.