lookup(place, callback, options)
Converts an address to geographic coordinates.
Declaration
lookup(
place: string,
callback: (error: Error | null, result?: GeocoderResponse) => void,
options?: GeocoderLookupOptions,
): number;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. - callback:
MapKit JS returns geocoding results asynchronously through a callback function. MapKit JS invokes the callback function with two arguments,
erroron failure anddataon success.error(Error). Contains an error code and descriptive message.data(Object). An array of places named Results, which is an object the system parses from a server-returned JSON response. Each place in Results has a Coordinate property and a Formattedaddress property. Results is an empty array if there isn’t a match.
- options:
The geocoder returns the most relevant results for a query. For example, a query for Paris returns 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 you can pass to cancel(id) to stop a pending request.
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.