A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/maps/geocoder below:

Class Geocoder | Apps Script

Class Geocoder

Stay organized with collections Save and categorize content based on your preferences.

Geocoder

Allows for the conversion between an address and geographical coordinates.
The example below shows how you can use this class find the top nine matches for the location "Main St" in Colorado, add them to a map, and then embed it in a new Google Doc.

// Find the best matches for "Main St" in Colorado.
const response = Maps.newGeocoder()
                     // The latitudes and longitudes of southwest and northeast
                     // corners of Colorado, respectively.
                     .setBounds(36.998166, -109.045486, 41.001666, -102.052002)
                     .geocode('Main St');

// Create a Google Doc and map.
const doc = DocumentApp.create('My Map');
const map = Maps.newStaticMap();

// Add each result to the map and doc.
for (let i = 0; i < response.results.length && i < 9; i++) {
  const result = response.results[i];
  map.setMarkerStyle(null, null, i + 1);
  map.addMarker(result.geometry.location.lat, result.geometry.location.lng);
  doc.appendListItem(result.formatted_address);
}

// Add the finished map to the doc.
doc.appendImage(Utilities.newBlob(map.getMapImage(), 'image/png'));
See also Detailed documentation geocode(address)

Gets the approximate geographic points for a given address.

// Gets the geographic coordinates for Times Square.
const response = Maps.newGeocoder().geocode('Times Square, New York, NY');
for (let i = 0; i < response.results.length; i++) {
  const result = response.results[i];
  Logger.log(
      '%s: %s, %s',
      result.formatted_address,
      result.geometry.location.lat,
      result.geometry.location.lng,
  );
}
Parameters Name Type Description address String an address Return

Object — a JSON Object containing the geocoding data, as described here

reverseGeocode(latitude, longitude)

Gets the approximate addresses for a given geographic point.

// Gets the address of a point in Times Square.
const response = Maps.newGeocoder().reverseGeocode(40.758577, -73.984464);
for (let i = 0; i < response.results.length; i++) {
  const result = response.results[i];
  Logger.log(
      '%s: %s, %s',
      result.formatted_address,
      result.geometry.location.lat,
      result.geometry.location.lng,
  );
}
Parameters Name Type Description latitude Number the latitude of the point longitude Number the longitude of the point Return

Object — a JSON Object containing the reverse geocoding data, as described here

See also setBounds(swLatitude, swLongitude, neLatitude, neLongitude)

Sets the bounds of an area that should be given extra preference in the results.

// Creates a Geocoder that prefers points in the area of Manhattan.
const geocoder = Maps.newGeocoder().setBounds(
    40.699642,
    -74.021072,
    40.877569,
    -73.908548,
);
Parameters Name Type Description swLatitude Number the latitude of the south west corner of the bounds swLongitude Number the longitude of the south west corner of the bounds neLatitude Number the latitude of the north east corner of the bounds neLongitude Number the longitude of the north east corner of the bounds Return

Geocoder — the Geocoder object to facilitate chaining of calls

See also setLanguage(language)

Sets the language to be used in the results.

// Creates a Geocoder with the language set to French.
const geocoder = Maps.newGeocoder().setLanguage('fr');
Parameters Name Type Description language String a BCP-47 language identifier Return

Geocoder — the Geocoder object to facilitate chaining of calls.

See also setRegion(region)

Sets a region to use when interpreting location names. The supported region codes correspond to the ccTLDs supported by Google Maps. For example, the region code "uk" corresponds to "maps.google.co.uk".

// Creates a Geocoder with the region set to France.
const geocoder = Maps.newGeocoder().setRegion('fr');
Parameters Name Type Description region String the region code to use Return

Geocoder — the Geocoder object to facilitate chaining of calls

See also

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-12-02 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["The Geocoder class enables conversion between addresses and geographic coordinates (latitude and longitude)."],["It provides methods for finding geographic points for an address (geocode) and vice-versa (reverseGeocode)."],["You can specify bounds for preferred results, language, and region for location interpretation."],["Geocoder uses a JSON object to represent the geocoding and reverse geocoding data."],["It leverages the Google Geocoding API for its functionality and supports various region codes."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4