Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Code cleanup in MapKitSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
bopang authored and pjbeaman committed Jul 24, 2013
1 parent 31a258e commit a98c0b6
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions MapKitSearch/AppDelegate.cs
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a98c0b6

Please sign in to comment.