I found MKLocalSearchCompleter is only available in iOS 9.3+, unfortunately my application needs to support up to 9.0+. I want to make a auto complete suggestions for location search in Swift 4.0. What are the alternatives of MKLocalSearchCompleter?
Is there any other better way to show auto suggested locations?
What have been tried:
I have used CLGeocoder, geocodeAddressString() but its not possible to use for auto completion search because changes in the search string is frequent so the api calls as well, which is not allowed by the API. What am I missing?
Related
The Mapbox web directions API supports avoiding motorways Link.
How is this done in the Mapbox iOS SDK?
The Mapbox Navigation SDK for iOS uses Directions objects to provide directions between waypoints. You may provide a RouteOptions object to each Direction to specify criteria for the results returned by the Mapbox Directions API. As noted in the changelog for the SDK here, on the RouteOptions object there is a roadClassesToAvoid option where you can specify a RoadClass object to avoid, such as motorway. The source code for the motorway RoadClass can be found here, namely:
public static let motorway = RoadClasses(rawValue: 1 << 3)
The Nav SDK's NavigationRouteOptions extends RouteOptions. So, to calculate directions avoiding motorways in your iOS app, you should specify the roadClassesToAvoid option on a NavigationRouteOptions passed to Directions.shared.calculate. This example for a basic navigation app is a great place to get started.
I came across tutorial http://www.raywenderlich.com/40870/augmented-reality-ios-tutorial-marker-tracking.
It uses String SDK, but that SDK is no longer active.
What are some alternatives ?
You will find a list of alternative AR SDKs along with a comparison of each here http://socialcompare.com/en/comparison/augmented-reality-sdks From what I can tell this list is pretty active and updated frequently.
I have done an implementation by adopting most of the concept from Apple's sample code of the MKlocalSearch from here
Currently for the auto complete, every time user is typing inside the search bar, I am sending a new request where I specified:
MkLocalSearchRequest.naturalLanguageQuery = searchBar.text
MkLocalSearchRequest.region = userlocation.region
But I get totally different set of response from sever comparing to Apple's default map app as shown in the image below
Then I capture the traffic and find that my request goes to https://gsp-ssl.ls.apple.com/search.arpc while Apple's goes to
https://gsp-ssl.ls.apple.com/auto_complete.arpc
Is there any way to tune the MkLocalSearchRequest to get the same set of response objects?
MkLocalSearchRequest will not perform auto complete on your search string, perhaps because Apple wants to limit the number of requests from 3rd party apps.
In theory you could reverse-engineer the requests and responses to https://gsp-ssl.ls.apple.com/auto_complete.arpc and then perform those requests yourself, not using MkLocalSearchRequest at all. But that would probably lead to your app being rejected on the App Store.
#TypingPanda - I don't have enough points to comment directly but: beware of using the Google places API! Although perhaps not immediately obvious, Google's terms and conditions state that any visual representation of Google places data needs to occur on a Google Map. Hope everything works out!
Since iOS 9.3 Apple has provided MKLocalSearchCompleter.
An MKLocalSearchCompleter object takes a partial search string and generates a list of potential completions. You use a search completer object to retrieve auto-complete suggestions for your own map-based search controls.
That's the class that uses https://gsp-ssl.ls.apple.com/auto_complete.arpc
It has quite similar syntax with MkLocalSearchRequest:
MKLocalSearchCompleter.queryFragment = searchBar.text
MKLocalSearchCompleter.region = userlocation.region
But for results you will need to listen delegate methods:
- (void)completerDidUpdateResults:(MKLocalSearchCompleter *)completer;
This might be a very stupid question for some people but I want to be make sure about this.
In iOS6 Apple has updated its Map application and added his own map. Now if I develop any native application and include map(MKMapView) into this so are their any changes which I should be aware of them?
Previously, I was using Google web service to fetch the latitude and longitude between two locations and draw direction. Does Apple provide its own web services for the same?
are their any changes which I should be aware of them?
MKMapView will still work fine, but the map it displays will look a little different. Also, if you limit your app to iOS versions that use only Apple's maps, you might not be subject to Google's terms and conditions. Read your agreements.
Does Apple provide its own web services for the same?
There's CLGeocoder. It's a class, not a web service, but that just makes it easier to use.
Using MKMapView framework didn't change just because the images are different. It should work fine.
Google's Terms Of Service say that you can't show their data on someone else's maps. So if your app is still getting data from a Google webservice you'll need to use the Google Map SDK that they have put out, not the usual MKMapView on iOS 6+.
If you are only using Google's webservice to turn a human readable address into lat/long then you can do that using CLGeocoder as Caleb suggested, but Google offer other services too.
I am using Google Places API to pull a list of resturants, and I am displaying them on map. However, since Apple has switched there map services over from Google in iOS 6.0, I am now in violation of Google's terms of use, which states that you must display Google data on a Google map.
"If your application displays Places API data on a map, that map must be provided by Google."
https://developers.google.com/places/policies#terms_of_use
I obviously need to change the map, because I am not going to release an application that is in violation. Any thoughts or suggestions on what to do? Should I go Google Maps with a web view? Does apple have some sort of Google Places API alternative?
Edit:
Using Google Maps through a web view is a hassle, i'd like to find an alternative to that, although it would technically work.
I decided to use Google Maps JavaScript API. Although, it is a little more difficult to deal with, mainly the JavaScript through Objective-C, it is a solution. The map is displayed through a web view, and I use JavaScript to interact with the map.
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
I will wait to accept this answer, to see if anyone else has any thoughts. I just wanted to post this, in case it helps someone else.
Edit:
Google recently released a Maps SDK for iOS, this is the better solution now.
https://developers.google.com/maps/documentation/ios/
I would try to directly contact Google, explaining the situation, and ask them for written permission to use Apple's maps. This is more a legal question than programming. One would think that Google is aware that you can no longer display their maps using Apple's API and that, even regardless of the map, they would want you to use their places, as doing so generates advertising revenue for them.
Agree with #Owen here - you could get permission to leave your app unchanged until some possible future date when you might have to change it, or could you definitely go to the effort of changing it now and then possibly have to change it again in the future for some other reason.
If you could get a 100% guarantee that you could change it once and never have to change it again then I'd say do it now, but nothing's certain.