Instance Method

lookup

Converts an address to geographic coordinates.

Declaration

Number lookup(String place, function callback, optional GeocoderLookupOptions options);

Parameters

place

A case-insensitive string to be converted to geographic coordinates: for example: "450 Serra Mall", "450 Serra Mall, Stanford", "450 Serra Mall, Stanford, CA USA". Delimiter characters are optional.

callback

Geocoding results are returned asynchronously via a callback function. This callback function is invoked with two arguments, error on failure and data on success. error contains an error code and text description of the error. data is an object with the following property:

  • results. An array of Place objects. Each Place object has several properties. If there is no match, results is an empty array.

options

The geocoder returns the most relevant results for a query. For example, a query for “Paris” will return results for Paris, France. Use GeocoderLookupOptions to constrain the search to specific countries, or to a desired area with a coordinate or region.

Return Value

This method returns a request ID, which is an integer that can be passed to cancel to abort a pending request.

Discussion

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

See Also

Getting Geocoder Results

GeocoderLookupOptions

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

reverseLookup

Converts a geographic coordinate to an address.

GeocoderReverseLookupOptions

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

GeocoderResponse

The response from a geocoder lookup or reverse lookup.

Place

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