An app for iOS and Android to find out when your Metro or Circulator bus or Metro train is coming to a stop near you, using WMATA and NextBus prediction data.
I'm making an app that shows all pizza places near your current location. I don't want to write all the annotations one by one because I want to show all the pizza places for a state. So I want to create a function that shows all the pizza places (not using local search). Using local search this would be the code:
func performSearch() {
matchingItems.removeAll()
let request = MKLocalSearchRequest()
request.naturalLanguageQuery = searchText.text
request.region = mapView.region
let search = MKLocalSearch(request: request)
search.start(completionHandler: {(response, error) in
if let results = response {
if let err = error {
print("Error occurred in search: \(err.localizedDescription)")
} else if results.mapItems.count == 0 {
print("No matches found")
} else {
print("Matches found")
for item in results.mapItems {
print("Name = \(item.name ?? "No match")")
print("Phone = \(item.phoneNumber ?? "No Match")")
self.matchingItems.append(item as MKMapItem)
print("Matching items = \(self.matchingItems.count)")
let annotation = MKPointAnnotation()
annotation.coordinate = item.placemark.coordinate
annotation.title = item.name
self.mapView.addAnnotation(annotation)
}
}
}
})
}
but I don't want to use local search because I want the annotations (pizza places) to appear by default (when I open the app I want the annotations to show). What function should I use?
I'm making an app that shows all pizza places near your current location. I don't want to write all the annotations one by one because I want to show all the pizza places for a state. So I want to create a function that shows all the pizza places (not using local search). Using local search this would be the code: func performSearch() {
}
but I don't want to use local search because I want the annotations (pizza places) to appear by default (when I open the app I want the annotations to show). What function should I use?