Skip to main content

Geocoding

The Geocoding service provides methods related to converting street addresses to or from longitude and latitude coordinates.

For a quick start and a ready made geocoding control, you might consider using our Single Search Add-on.

Geocoding

Geocoding allows you to retrieve longitude and latitude coordinates for a given address. Geocoding is done by making a call to the TrimbleMaps.Geocoder.geocode method. The geocode method takes a single configuration object with four possible properties.

Input Parameters

Parameter Name Description
address Object with the following properties: addr, city, state, zip, region.
listSize Number of results to be returned.
success Function called when the geocoding completes.
failure Function called when the geocoding fails.

Example

TrimbleMaps.Geocoder.geocode({
  address: {
    addr: "1 Independence Way",
    city: "Princeton",
    state: "NJ",
    zip: "08540",
    region: TrimbleMaps.Common.Region.NA
  },
  listSize: 1,
  success: function(response) {
    console.log(response);
  },
  failure: function(response) {
    console.log(response);
  }
});

The response from the geocode method is an array of JavaScript objects that contains the longitude and latitude coordinates for the address if the address could be resolved. In addition, the object contains a normalized address object as well as an array of error/warning messages.

Reverse Geocoding

Reverse Geocoding allows you to retrieve the nearest address for given longitude and latitude coordinates using the TrimbleMaps.Geocoder.reverseGeocode method.

Input Parameters

Parameter Name Description
lonLat Longitude/Latitude object to be reverse geocoded.
region Enumeration for the region.
success Function called when the reverse geocoding completes.
failure Function called when the reverse geocoding fails.

Example

TrimbleMaps.Geocoder.reverseGeocode({
  lonLat: new TrimbleMaps.LngLat(-122.31693, 47.60784),
  region: TrimbleMaps.Common.Region.NA,
  success: function(response) {
    console.log(response);
  },
  failure: function(response) {
    console.log(response);
  }
});
Last updated December 11, 2025.