I am using MKLocalSearchRequest() to find locations mathcing a search from the previous view and it works fine on WiFi but with LTE its showing matches from another state...
Is there a way to set the search region or parameters to search within the area set as my location by the location manger?
my code for this saerch:
let request = MKLocalSearchRequest()
request.naturalLanguageQuery = (foodLocation)
request.region = regionSearch
/
let search = MKLocalSearch(request: request)
search.start(completionHandler: {(response, error) in
/
if error != nil {
print("Error occured in search: \(error!.localizedDescription)")
/
/
} else if response!.mapItems.count == 0 {
print("No matches found")
let alert = UIAlertController(title: "Whoops!", message: "There were no matches or the web service went down. Please try again.", preferredStyle: .alert)
let alertAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alert.addAction(alertAction)
self.present(alert, animated: true, completion: nil)
/
} else {
print("Matches found")
/
for item in response!.mapItems{
/
print("Name = \(String(describing: item.name))")
print("Phone = \(String(describing: item.phoneNumber))")
/
self.matchingItems.append(item as MKMapItem)
print("Matching items = \(self.matchingItems.count)")
let annotation = MKPointAnnotation()
annotation.title = item.name
annotation.coordinate = item.placemark.coordinate
annotation.subtitle = item.phoneNumber
self.showMap.addAnnotation(annotation)
/
self.rowCount += 1
/
self.locationName.append(item.name!)
if item.phoneNumber != nil{
self.locationPhone.append(item.phoneNumber!)
}
/
else{
self.locationPhone.append("")
}
if item.url != nil {
self.locationWeb.append(String(describing: item.url!))
}
/
else {
self.locationWeb.append("")