Contents

lookup(place, options)

Converts an address to geographic coordinates.

Declaration

lookup(
    place: string,
    options?: GeocoderLookupOptions,
): Promise<GeocoderResponse>;

Parameters

  • place:

    A case-insensitive string MapKit JS converts to geographic coordinates, such as: “San Francisco City Hall”, “San Francisco City Hall, San Francisco”, “San Francisco City Hall, San Francisco, CA USA”. Delimiter characters are optional.

  • options:

    Options that constrain geocoder lookup results to a specific area or a specific language. See Geocoderlookupoptions.

Return Value

A promise that resolves with a GeocoderResponse on success, or rejects with an Error on failure.

Discussion

Geocoding converts a human-readable address to latitude and longitude coordinates. You can use Geocoder to look up coordinates for a city, landmark, or address.

The resolved GeocoderResponse contains an array of places named results. Each place in results has a coordinate property and a formattedAddress property. results is an empty array if there isn’t a match.

Pass an AbortSignal from an AbortController to the signal option to allow the controller to cancel a pending request. When the controller aborts, the promise it returns rejects with a DOMException whose name is "AbortError".

See Also

Getting geocoder results