A geocoder that converts human-readable addresses to geographic coordinates and vice versa.


interface mapkit.Geocoder


When using MapKit JS to show Apple Maps on a website, the geocoder handles forward and reverse geocoding. Since geocoding is performed on the server, the geocoder requires a network connection and handles calls asynchronously.

Provide context to the geocoder in order to get the most relevant results. The geocoder can obtain context from these sources:

  • The user's location in the browser's Geolocation API. The geocoder assigns higher relevancy to results near the user. Note that asking for the user's location requires the user's permission. If this option is enabled, the browser asks the user for permission (some browsers remember this setting for a day). By default, this option is disabled.

  • Lookup options. Your website can provide context in the geocoder lookup options as a coordinate or region. For example, if a user types “Brisbane” into a map text field and the web page invokes the geocoder without context, the geocoder returns the major city in Australia. If, however, the map displays San Francisco and its environs, a geocoding request with this region as context returns the nearby city of Brisbane instead.

  • The user's IP address. Of the three forms of context, this is the least accurate but the only one certain to be present. The user's IP is a granular IP location that is not logged or stored.


Creating a Geocoder Object


Initialize a geocoder object and set optional language and user location properties.


Initialization options for geocoder objects.


A Boolean value that indicates whether the geocoder should return results near the user's current location.


A language ID that determines the language used for displaying addresses.

Getting Geocoder Results


Converts an address to geographic coordinates.


Options that constrain geocoder lookup results to a specific area or set a language for results.


Converts a geographic coordinate to an address.


An option that constrains reverse lookup results to a specific language.


The response from a geocoder lookup or reverse lookup.


A place object returned from a geocoder lookup or reverse lookup.

Canceling a Geocoder Request


Cancels the pending lookup or reverse lookup specified by its request ID.