Scandit.Geocoder

Methods

(static) getFromLocation(lat: double, lng: double, maxResults?: integer): Promise

Converts location coordinates (latitude, longitude) into a Location object (includes human readable address details)

Parameters:
Name Type Attributes Default Description
lat double

Latitude

lng double

Longitude

maxResults integer <optional>
5

Max number of results to return

Returns:
Promise

Promise which is resolved to an array of Location objects.

Can resolve to an error with code:

Examples
Get the address that corresponds to the current location of the device
  • JavaScript
  • ES6
Scandit.Geolocation.getPosition().then(function(position) {
  Scandit.Geocoder.getFromLocation(position.latitude, position.longitude).then(function(location) {
    var address = location[0].addressLines.join(', ');
    console.log(address); // outputs the address of the current location
  });
});
Scandit.Geolocation.getPosition().then(position => {
  Scandit.Geocoder.getFromLocation(position.latitude, position.longitude).then(location => {
    const address = location[0].addressLines.join(', ');
    console.log(address); // outputs the address of the current location
  });
});
Get the address that corresponds to latitude-longitude coordinates
  • JavaScript
  • ES6
Scandit.Geocoder.getFromLocation(47.3824887, 8.5342019).then(function(location) {
  var address = location[0].addressLines.join(', ');
  console.log(address);
});
Scandit.Geocoder.getFromLocation(47.3824887, 8.5342019).then(location => {
  const address = location[0].addressLines.join(', ');
  console.log(address);
});

(static) getFromUserQuery(query: string, maxResults?: integer): Promise

Converts user-supplied query into a Location object

On iOS devices, there is currently a 1 query per minute limit imposed by Apple.

Parameters:
Name Type Attributes Default Description
query string

User-supplied query

maxResults integer <optional>
5

Max number of results to return

Returns:
Promise

Promise which is resolved to an array of Location objects.

Can return an error with code:

Examples
Get the proper address of a user query
  • JavaScript
  • ES6
Scandit.Geocoder.getFromUserQuery('Limmatstrasse 73, Zurich').then(function(location) {
  var address = location[0].addressLines.join(', ');
  console.log(address);
});
Scandit.Geocoder.getFromUserQuery('Limmatstrasse 73, Zurich').then(location => {
  const address = location[0].addressLines.join(', ');
  console.log(address);
});

Type Definitions

Location

Location object, as returned by getFromUserQuery and getFromLocation

Properties:
Name Type Description
addressLines string[]

Formatted address lines

adminArea string

Region/State/Administrative area

countryCode string

The country code

countryName string

The country name

featureName string

Place label, see "Place labels on Google Maps"

lat integer

Latitude

lng integer

Longitude

locality string

Locality or city

postalCode string

Postal/Zip code

subThoroughfare string

Street number

thoroughfare string

Street name