Address resolution options for iOS app development

Which one to choose?

Avinas Udayakumar
14 min readMar 15, 2023

In this article, you will get a brief overview of different types of address resolution options for iOS app development which is one of the best options for an app development.

In our iOS app development, we utilize many technologies for feature implementation. There are several mobile apps available in different usage categories. Entertainment, education, games, and so on are part of it. Each category has its own platform uniqueness and feature usage. Similarly, there are plenty of online ordering apps available in the App Store too.

These online ordering apps are there to serve our needs. As an end user, you can use it for food ordering, purchasing goods and services, delivery-related matters, etc. One of the main features of the above mentioned apps satisfies the user’s requirement by allowing an address to be added for delivery.

Best address resolution options

  • Google Geocoding API
  • Mapbox Geocoding API
  • HERE Geocoding API
  • Google Place Autocomplete
  • Apple’s MKLocalSearchCompleter
  • Using Google Maps/Apple MapKit

Now let’s take a look at the best address resolution options mentioned above.

Geocoding APIs

  1. Google Geocoding API

Among the many services offered by Google for developers, geocoding is one API that supports to resolve addresses. It basically calls an endpoint and receive address responses from Google.

How to configure ?

In order to use this API, you may need an API key from Google Cloud console. You need to create a Google Cloud account and log into that console with the following link

Google developer cloud console

You can interact with the “APIs & Services” section in the left pane and enable the services you are going to use from Google. As well as, under credentials, you can create your Google API key which you will use in all kinds of Google services.

Google developer cloud console credentials section

Once you have completed the configuration process, simply call this endpoint. This will refer you to the suggested addresses.

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

As mentioned in the google developer document, you will obtain the JSON response. You can map the JSON response and use it according to your address requirements. You can use the reverse geocoding APIs to resolve the address for the specific latitude and longitude. But in this article, we are only considering to resolve the address through user inputs (typed address/forward geocoding).

2. Mapbox Geocoding API

Mapbox is also one of the popular service like Google that provides services for developers. Under the services, Mapbox geocoding is also one of the APIs that Mapbox delivers to resolve addresses. This calls an endpoint and retrieves the address response from Mapbox in the same way as Google API.

How to configure ?

This configuration process is also the same as Google that you may need an access token to proceed with the API. Log in to the dashboard using the link below and create the token.

Mapbox developer console account section

Once you have completed the setup process, simply call this endpoint. This will provide you the address suggestions as a JSON response.

https://api.mapbox.com/geocoding/v5/mapbox.places/Washington.json?limit=2&access_token=YOUR_MAPBOX_ACCESS_TOKEN

In this API, you can limit the results by adding the query parameter
“Limit =5”. By default Mapbox yields 5, and 10 as the maximum. Depending on the limit, it will provide the JSON result as stated in the developer’s documentation. Numerous choices similar to Google geocoding are offered by this Mapbox API. We are only focusing on user inputs/forward geocoding.

3. HERE Geocoding API

HERE developer provides several services like Google & Mapbox. This is another excellent option for our address resolving requirements. Further, the functionality for the geocoding API will be covered in more detail.

How to configure ?

You might need an API key in order to use the geocoding API. To continue with this setup, click the following link to log in to the dashboard and continue generating the API key to complete this setup.

HERE developer projects console
HERE developer api creation section

Once the configuration is complete, you are ready to use the API. You can get the JSON response by simply calling the endpoint.

https://geocode.search.hereapi.com/v1/geocode?q=Invalidenstr+117+Berlin&apiKey={YOUR_API_KEY}

As mentioned in the HERE developer’s documentation, you will be getting the address suggestions. This approach is on user inputs/forward geocoding.

Comparison of Geocoding APIs

Now you have an idea about different types of geocoding APIs for our app development. All these APIs are provided by third-party SDKs. Therefore, these are not free. Until you reach the free limit, you can use this as a free version, after reaching the limit we may need to consider the pricing and availability.

Google Geocoding API Pricing

Google geocoding pricing section

Mapbox Geocoding API Pricing

Mapbox pricing section

HERE Geocoding API pricing

Here developer pricing section

By looking at the above details each option has its price level and free request limits. If we take Google, up to 200$ it’s free. After reaching the limit pricing will be started. Refer to the comparison table and check the different pricing levels.

Pricing Level Comparison

Geocoding APIs pricing level table

Summary

Geocoding APIs comparison summary table

In a summary, by looking at the pricing and overall comparison Google API is the best choice for geocoding. But pricewise it’s a bit higher than the other two options. Data availability for Google is better than the other two options, it depends on the need that you are selecting the option.

Either option is fine to use, If you consider the price Mapbox/HERE geocoding is the best option. If you consider the data Google is the one because it is worldwide popular.

Autocomplete SDKs

Autocomplete is another way of resolving addresses, compared to geocoding APIs, it’s a more efficient way of getting the results. Because this approach also uses APIs to retrieve the suggestions, but this is not a direct approach, It occurs through a SDK.

There are several autocomplete options available to use. Even Mapbox and HERE developers provide these options with various price levels. In this article, we will focus on two popular options. I.e Google and Apple autocomplete options for developing iOS app.

  1. Google Place Autocomplete

Google Place Autocomplete is one of the best and the most popular options for address resolution. To integrate this, we may need to include the Google Places SDK in our Xcode project.

There are two options, either you can use the CocoaPods or directly use the Google SDK static framework.

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '13.0'

target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
pod 'GooglePlaces', '7.4.0'
end

Refer to the following link to use other options, excluding CocoaPods.

Once you’re done configuring your Xcode project, you may need to add the following code snippet to the Xcode project to initialize the SDK.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

[GMSPlacesClient provideAPIKey:@"YOUR_API_KEY"];

return YES;
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

GMSPlacesClient.provideAPIKey("YOUR_API_KEY")

return true
}

As already mentioned in the geocoding section of Google, under “How to configure?” you must replace the “YOUR_API_KEY” by the actual API key that you have created. Depending on the language of the project(Objective-C/Swift) refer to the developer’s documentation and implement the autocomplete view within the project.

Once you’re done implementing, you are good to go with these autocomplete options. Google will provide the search result as an “GMSPlace” object. Which includes all the details of the locations you need, you can use the details as per the different needs of your project.

Google autocomplete example Google Maps

When implementing autocomplete, there are three options available for designing your UI as they are,

In this example, let’s take a look at “Add a full-screen control”

Google places full screen control autocomplete view

As shown in the example above, you’re required to provide your input. Using the input provided by the user, Google will endeavour to provide relevant address suggestions as much as possible. By clicking on every suggestion you will get the details of the location.

2. Apple’s MKLocalSearchCompleter

Another popular and easy option for iOS developers is “MKLocalSearchCompleter” which is an option built into Xcode IDE with the help of the MapKit framework. We may use this autocomplete option for our address resolution requirements.

Apple Autcomplete view in Apple Map

Compared to Google Place Autocomplete it’s easy to integrate since it’s a built-in option for iOS. There is no requirement to onboard third parties.

Simply follow the below code snippet to initiate this in your project. For more details on implementation refer the official Apple developer’s document.

import MapKit

var searchCompleter = MKLocalSearchCompleter()
var searchResults = [MKLocalSearchCompletion]()

searchCompleter.delegate = self
searchCompleter.queryFragment = searchField.text!
@import MapKit;

MKLocalSearchCompleter *searchCompleter = [[MKLocalSearchCompleter alloc] init];
NSArray *searchResults = nil;

searchCompleter.delegate = self;
searchCompleter.queryFragment = serachText;

Following the Apple developer’s guide, implement the delegate methods and views to show the result in the table view. It’s entirely managed by Apple. As a result, support issues do not need to be a concern.

Apple’s MapKit / MKLocalSearchCompleter view

Comparison of Autocomplete Options

Both autocomplete options are very best ways to resolve an address. But still, there are a few instances of edge using these options. Primarily prices and data availability. As we already know, Google products are not free of charge. Same as Google geocoding API, this autocomplete also has a different pricing.

Google Autocomplete Pricing

Google autocomplete pricing

Apple’s MKLocalSearchCompleter

Apple’s MKLocalSearchCompleter is completely free to meet your address resolutions requirements.

Summary

Autocomplete comparison summary table

To summarize by looking at the overall comparison, Google place autocomplete is the best choice for autocomplete addresses. Because of the data availability. But when you look at the pricing, Apple is going to be number one. Because it’s completely free and built-in for iOS, there’s no need for any third-party integrations.

Overall, when considering data availability, choose Google APIs. If we consider Apple most options are just like Google. In this case, generally MKLocalSearchCompleter of Apple is the winner for our address autocomplete, Which is the easiest way to implement and sustain.

Resolve addresses using Maps

Using Maps to resolve the address is another option for address resolution option during app development. There are many map support providers for app development, even Mapbox, HERE also provides map support.

In this order, a very popular map service provider is Google which is used by many countries/many services. Because of its availability and popularity, Google Maps is among the first choice of developers.

Beside Google Maps, Apple’s MapKit is there which is also one of the best map support providers. But taking into account the availability of Apple MapKit is not like Google Maps. The usage capacity of Apple MapKit is limited to countries. (This availability is taken into account when using maps in iOS apps. Check the link below to know the availability of Apple Mapkit in the countries.)

While we have many options, let’s check out two popular options , iOS MapKit and Google Maps SDKs.

  1. Google Maps iOS SDK

The worldwide availability and availability of data makes Google Maps more popular than other service providers. Using the map, we can indicate a location and resolve the address using latitude and longitude. Simply, we do reverse geocoding using map support and data response.

Google Maps view

The end user can fully interact with the map and identify locations that meet their needs. The Google developer guide provides all the necessary information on how to integrate Google Maps with your iOS app.

Once the integration is complete, we are ready to use Google Maps to resolve our address requirements.

Point the marker/annotation in the map view where you must resolve the address. By using the pin/marker you can get the latitude and longitude of the pointed pin, using the reverse geocoding API / method you can retrieve the complete address of the pointed pin.

Google Maps SDK provides the code support to resolve the address using latitude and longitude as specified in the following code snippet.

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
  let geocoder = GMSGeocoder()
geocoder.reverseGeocodeCoordinate(position) { response, error in

if error != nil {
cprint("reverse geodcode fail: \(error!.localizedDescription)")
}
else {
if let places = response?.results() {

if let place = places.first {

if let lines = place.lines {
print("GEOCODE: Formatted Address: \(lines)")
}
}
else {
print("GEOCODE: nil first in places")
}
}
else {
print("GEOCODE: nil in places")
}
}
}

Refer to the following link for more details about reverse geocoding or using Google Maps SDK methods.

Google Maps point annotation

Since we referenced other Google products, this map is not free either. Depending on utilization, there is a price. Since this is a third party SDK provider so we may need to embed the SDK in our Xcode project to use this Google Maps support.

Google Maps pricing
  1. Apple MapKit

Apple MapKit is another popular solution for any kind of map-related activity. Using Apple MapKit in our project is not a big challenge because it is integrated into the platform (iOS/ Xcode). Therefore, there is no need to worry about the third-party libraries.

Apple Map pointing to specific location

Once you’re done integrating Apple MapKit into your project, you can start using the map functionality for your address resolution needs. Our major concern is to resolve addresses for a variety of purposes. You can use the annotation to indicate to the exact location on the map and you can use reverse geocoding to resolve the addresses.

Using Apple MapKit for address resolution

Same as Google’s reverse geocoding API, use the Apple’s “CLGeocoder” inbuilt method to get the place details. As shown in the following example code snippet, get an idea of how to use the map responses.

lazy var geocoder = CLGeocoder()

// Create Location
let location = CLLocation(latitude: lat, longitude: lng)

// Geocode Location
geocoder.reverseGeocodeLocation(location) { (placemarks, error) in
// Process Respons
}
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];

[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {

if (!error) {
CLPlacemark *placemark = placemarks.firstObject;

Address *address = [[Address alloc] init];

address.addressName = placemark.name;
address.latitude = [NSNumber numberWithDouble:placemark.location.coordinate.latitude];
address.longitude = [NSNumber numberWithDouble:placemark.location.coordinate.longitude];
address.streetNumber = placemark.subThoroughfare;
address.streetAddress = placemark.thoroughfare;
address.city = placemark.locality;
address.state = placemark.administrativeArea;
address.country = placemark.country;
address.zipCode = placemark.postalCode;
address.formattedAddress = [address formattedAddress];

completionHandler(address);
}
else {
completionHandler(nil);
}
}];

If we use Apple MapKit, it’s free and embedded in iOS. However, Apple MapKit’s feature support is limited by country. If you’re targeting users in multiple countries, Google Maps is the best choice. If you are targeting a specific country user group and looking at pricing, check out the Apple MapKit support for that country. You can definitely implement Apple MapKit support without any doubt.

It doesn’t mean Apple MapKit does not function like Google Maps. Apple MapKit is the modern equivalent of Google Maps services. Each year Apple adds more features and updates to Apple MapKit to make it more accessible and functional for users and developers.

As a developer, it’s up to you choose the map which suits your needs. According to my analysis and comparison, using the native map support in Apple MapKit is a more viable solution.

Conclusion

I hope this blog has given you an overview of the different types of address resolution options for iOS development. Each feature has its own way of grabbing user’s attention. Choosing the best and appropriate features for your app development will make your app more efficient and provide a better user experience.

Overall, when considering geocoding and map support, Google is at the top of the list, and the runner-up is Apple support(This ranking is based on my analysis and comparison). It depends on your app’s needs/requirements. Go to either Apple/Google.

As per my understanding, all the options are good for app development and they never fail to fulfil user requirements. Your application’s requirement will decide the best solution for you. For more information about the mentioned features, please follow up the official documentation attached in this article.

--

--