Choose the right API for the query type
Apple Maps exposes three ways to resolve a location query, and picking the right one affects both result quality and quota consumption.Full or nearly-complete address → Geocode
Full or nearly-complete address → Geocode
When you have a well-formed street address, use Geocoding a vague or fuzzy string (e.g., just a business name) produces poor results. Use Search or Autocomplete instead.
api.geocode(). It is optimized for exact or near-exact address strings and returns precise coordinates and structured address components.Name + city or region → Search
Name + city or region → Search
When you have a business name and some geographic context, use
api.search(). It handles natural-language queries more flexibly than Geocode.Partial name or typeahead → Autocomplete
Partial name or typeahead → Autocomplete
For incremental input (e.g., a search-as-you-type UI), use To get full place details for a selected suggestion, call
api.autocomplete(). It returns fast, lightweight completions without fetching full place details.api.resolveCompletionUrl(result.completionUrl()).Always provide a location hint when possible
For name-only or ambiguous queries, passing auserLocation significantly improves result relevance. Without it, Apple Maps has no geographic context for ranking results.
UserLocation.fromLatitudeLongitude() accepts decimal degrees. Pass the user’s last known position whenever it is available. The same .userLocation() builder method is available on SearchInput, SearchAutocompleteInput, and GeocodeInput. For DirectionsInput, use .userLocation(RouteLocation) — it accepts a RouteLocation rather than a UserLocation.
Use try-with-resources to manage the client lifecycle
AppleMaps implements AutoCloseable and manages an underlying HttpClient. Use try-with-resources to ensure the client is closed and its resources are released when you are done.
Load the token from environment variables
Never hardcode your authorization token in source code. Load it from an environment variable or JVM system property:origin claim, supply it via the two-argument constructor:
Be aware of quota costs
Apple provides a daily service-call quota shared across your Apple Developer membership. Each call togeocode, reverseGeocode, autocomplete, search, or directions counts as one service call.
When you exceed the daily quota, the API responds with HTTP 429 Too Many Requests. To request additional capacity, contact Apple through the Maps developer dashboard.
Handle errors explicitly
The SDK throws two distinct runtime exception types. Catch them separately to distinguish between API-level failures and network-level failures.| Exception | When thrown | Useful fields |
|---|---|---|
AppleMapsApiException | Apple Maps Server returned a non-2xx response | statusCode(), responseBody() |
AppleMapsClientException | Network or I/O failure | getCause() for the underlying exception |
RuntimeException subclasses, so you are not required to declare them in method signatures. Catch them at the appropriate boundary (controller, use-case, or job handler) and apply your application’s retry or alerting policy.
Set a custom timeout
The default request timeout is 10 seconds. Pass aDuration to the constructor to override it: