A geocoder that converts human-readable addresses to geographic coordinates and vice versa.
- MapKit JS 5.0+
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.