User Tools

Site Tools


thinkgeo_cloud_javascript_client_apis

This is an old revision of the document!


ThinkGeoCloudClient-js

NameSapce

tg is the abbreviation of ThinkGeo, the namespace of ThinkGeoCloudClient-js

tg.ColorClient

A class provides the methods to access the ColorUtilities APIs. Generats an diversified family of colors by an input color or a random base color.

Syntax

var colorClient = new tg.ColorClient('Your-Cloud-Service-Api-Key');

Parameters

Name Type Description
apiKey string An API key for access to ThinkGeo Cloud services, it can be created following the guide

Return Value

a color object to access the ColorUtilities APIs in ThinkGeo Cloud service.

colorClient.getColorsInAnalogousFamily(options, callback)

Get a family of colors based on three analogous hues.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInAnalogousFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer A number of output colors desired. The value must be between 3 and 54.
color string A base color. Two analogous hues will be found for you. If null, use random color.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the input Color. Supported formats: Hex, RGB, HSL. If not specified, we will try to parse the inputColor as Hex first, then RGB.
callback function the callback for response

colorClient.getColorsInComplementaryFamily(options, callback)

Get a family of colors based on two complementary hues.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInComplementaryFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer The total number of colors you want to be returned. The value must be between 2 and 36.
color string A base color. A complementary hue will be found for you.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the input Color. Supported formats: Hex, RGB, HSL. If not specified, we will try to parse the input Color as Hex first, then RGB.
callback function the callback for response

colorClient.getColorsInContrastingFamily(options, callback)

Get a family of colors based on two contrasting hues.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInContrastingFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer The total number of colors you want to be returned. The value must be between 2 and 36.
color string A base color. A contrasting hue will be found for you.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the input Color. Supported formats: Hex, RGB, HSL. If not specified, we will try to parse the input Color as Hex first, then RGB.
callback function the callback for response

colorClient.getColorsInHueFamily(options, callback)

Get a family of colors with the same hue and sequential variances in lightness and saturation.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInHueFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer The total number of colors you want to be returned. The value must be between 1 and 255.
color string A base color. A contrasting hue will be found for you.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the input Color. Supported formats: Hex, RGB, HSL. If not specified, we will try to parse the input Color as Hex first, then RGB.
callback function the callback for response

colorClient.getColorsInQualityFamily(options, callback)

Get a family of colors with qualitative variances in hue, but similar lightness and saturation.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInQualityFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer The total number of colors you want to be returned. The value must be between 1 and 255.
color string The color on which you want to base the color collection.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the input Color. Supported formats: Hex, RGB, HSL. If not specified, we will try to parse the input Color as Hex first, then RGB.
callback function the callback for response

colorClient.getColorsInTetradFamily(options, callback)

Get a family of colors based on a harmonious tetrad of hues.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInTetradFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer The total number of colors you want returned. The value must be between 4 and 72.
color string A base color. Three harmonious hues will be found for you to create a tetrad.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the inputColor. Supported formats: Hex, RGB, HSL. f unspecified, we will try to parse the inputColor as Hex first, then RGB.
callback function the callback for response

colorClient.getColorsInTriadFamily(options, callback)

Get a family of colors based on a harmonious triad of hues.

Syntax

  var options = {
      numberOfColors: 25
  };
  var callback = function (status, response) {
      console.log(response);
  };
  colorClient.getColorsInTetradFamily(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
numberOfColors integer The number of colors you want returned. The value must be between 3 and 54.v
color string The color on which you want to base the colors collections.
outFormat string Hex The format in which you want the output colors. Supported formats: Hex, RGB, HSL.
inFormat string Hex/RGB The format of the inputColor. Supported formats: Hex, RGB, HSL. f unspecified, we will try to parse the inputColor as Hex first, then RGB.
callback function the callback for response

tg.ElevationClient

A class provides the methods to access the Elevation APIs. Get the elevation of a geometry, include point, line, polygon.

Syntax

var elevationClient = new tg.ElevationClient('Your-Cloud-Service-Api-Key');

Parameters

Name Type Description
apiKey string An API key for access to ThinkGeo Cloud services, it can be created following the guide

Return Value

a elevation object to access the Elevation APIs in ThinkGeo Cloud service.

elevationClient.getElevationOfPoint(options, callback)

Get the elevation of a point.

Syntax

  var options = {
      pointY: 33.128367, 
      pointX:-96.809847,
      srid: 4326,
      elevationUnit:'Feet'
  };
  var callback = function (status, response) {
      console.log(response);
  };
  elevationClient.getElevationOfPoint(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
pointY number The Y coordinate of the point.
pointX number The X coordinate of the point.
srid integer 4326 The SRID (coordinate system) of the input Point.
proj4String string The Proj4 (coordinate system) of the input Point.
elevationUnit string “Feet” The unit of measure in which the elevation result is expressed.
callback function the callback for response

elevationClient.getElevationOfPoints(options, callback)

Get the elevations of all the points in a collection (up to 1,000 points maximum).

Syntax

   var options = {
      body:[
            {
               "coord":"33.128367,-96.809847",
               "srid":4326,
               "elevationUnit":"Meter"
            }
      ]
      srid: 4326,
      elevationUnit:'Meter'
  };
  var callback = function (status, response) {
      console.log(response);
  };
  elevationClient.getElevationOfPoints(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
body array A collection of point in JSON, the srid, proj4String and elevationUnit can be individually specified for each point.
srid integer 4326 The common SRID (coordinate system) for points which hasn't been specified.
proj4String string The common Proj4 (coordinate system) for points which hasn't been specified.
elevationUnit string “Feet” The unit of measure in which the elevation result is expressed.
callback function the callback for response

elevationClient.getElevationOfLine(options, callback)

Get the elevation of points along a line.

Syntax

 var options = {
      wkt: 'LINESTRING(-10717751.685805485 3864388.620499513,-10717359.946035523 3864570.1584416907)',
      srid: 3857,
      numberOfSegments:5,
      elevationUnit:'Meter',
  };
  var callback = function (status, response) {
      console.log(response);
  };
  elevationClient.getElevationOfPoints(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
wkt string The Well Known Text (WKT) of a line feature to get the elevation.
srid integer 4326 The SRID (coordinate system) of the input line.
proj4String string The Proj4String (coordinate system) of the input line.
elevationUnit string “Feet” The unit of measure in which the elevation result is expressed.
numberOfSegments integer Splits the requested line into this many segments, then calculates elevation of each point joining the segments.
IntervalDistance integer Splits the requested line into intervals of this length. The unit of measure for this distance is specified by the IntervalDistanceUnit parameter.
IntervalDistanceUnit string “Feet” The unit of measure in which the IntervalDistance is expressed.
callback function the callback for response

elevationClient.getGradeOfLine(options, callback)

Get the grade (slope) of a line, optionally split into segments.

Syntax

 var options = {
      wkt: 'LINESTRING(-10717751.685805485 3864388.620499513,-10717359.946035523 3864570.1584416907)',
      srid: 3857,
      numberOfSegments:5,
      elevationUnit:'Meter',
  };
  var callback = function (status, response) {
      console.log(response);
  };
  elevationClient.getGradeOfLine(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
wkt string The Well Known Text(WKT) of the line feature to get the grade.
srid integer 4326 The SRID (coordinate system) of the input line.
proj4String string The Proj4String (coordinate system) of the input line.
elevationUnit string “Feet” The unit of measure in which the elevation result is expressed.
numberOfSegments integer Splits the requested line into this many segments, then calculates elevation of each point joining the segments.
IntervalDistance number Splits the requested line into intervals of this length. The unit of measure for this distance is specified by the IntervalDistanceUnit parameter.
IntervalDistanceUnit string “Feet” The unit of measure in which the IntervalDistance is expressed.
callback function the callback for response

elevationClient.getElevationOfArea(options, callback)

Get the elevation of a matrix of points within an area

Syntax

 var options = {
      wkt: 'POLYGON((-10717723.021919878 3864742.1417553322,-10718038.324661555 3864426.839013656,-10716901.323865812 3864503.2760419413,-10717723.021919878 3864742.1417553322))',
      srid: 3857,
      numberOfSegments:5,
      elevationUnit:'Meter',
  };
  var callback = function (status, response) {
      console.log(response);
  };
  elevationClient.getElevationOfArea(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
wkt string The Well Known Text (WKT) of a polygon feature to get the elevation.
srid integer 4326 The SRID (coordinate system) of the input polygon.
proj4String string The Proj4String (coordinate system) of the input polygon.
elevationUnit string “Feet” The unit of measure in which the elevation result is expressed.
numberOfSegments integer Splits the requested line into this many segments, then calculates elevation of each point joining the segments.
IntervalDistance number 1000.0 The distance between every two points in the area matrix. Elevation of each point will be calculated and returned. Defaults to 1000.0. The unit of measure for this distance is specified by the IntervalDistanceUnit parameter.
IntervalDistanceUnit string “Feet” The unit of measure in which the IntervalDistance is expressed.
callback function the callback for response

tg.MapsClient

A class provides the methods to access the WorldImagery APIs.

Syntax

var mapClient = new tg.MapsClient ('Your-Cloud-Service-Api-Key');

Parameters

Name Type Description
apiKey string An API key for access to ThinkGeo Cloud services, it can be created following the guide

Return Value

a map object to access the Map APIs in ThinkGeo Cloud service.

mapClient.getRasterTile(options, callback)

Get a Maps raster tile by XYZ.

Syntax

  var options = {
      z: 3, 
      x: 2,
      y: 3,
      projection: 3857,
      mapType:'light',
      tileSize:512
      tileResolution:1
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapClient.getRasterTile(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
z integer The Z value (zoom level) of the tile to get.
x integer The X value (matrix column) of the tile to get.
y integer The Y value (matrix row) of the tile to get.
projection integer The SRID in which to generate the tile. Currently only “3857” is supported.
mapType string The style for the requested tile, include 'light', 'dark', 'hybrid', 'aerial', 'transparentBackground'
tileSize integer The size of the tile to be returned, include 512,256.
tileResolution integer The resolution for the request tile. include 1,2.
callback function the callback for response

mapClient.getVectorTile(options, callback)

Get a Maps Streets vector tile by XYZ.

Syntax

  var options = {
      z: 3, 
      x: 2,
      y: 3,
      projection: 3857
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapClient.getVectorTile(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
z integer The Z value (zoom level) of the tile to get.
x integer The X value (matrix column) of the tile to get.
y integer The Y value (matrix row) of the tile to get.
projection integer The SRID in which to generate the tile. Currently only “3857” is supported.
callback function the callback for response

tg.ProjectionClient

A class that provides the methods to access the GIS Server Projection APIs. Converts geometry in Well Known Text format from one spatial reference system to another.

Syntax

var projectionClient = new tg.ProjectionClient('Your-Cloud-Service-Api-Key');

Parameters

Name Type Description
apiKey string An API key for access to ThinkGeo Cloud services, it can be created following the guide

Return Value

a project object to access the Projection APIs in ThinkGeo Cloud service.

projectionClient.project(options, callback)

Converts a geometry from one spatial reference system to another.

Syntax

  var options = {
    pointX: 31.9000,
    pointY: -55.0000,
    fromProj: 4326,
    toProj: 3857
  };
  var callback = function (status, response) {
      console.log(response);
  };
  projectionClient.project(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
pointX number The X coordinate of the point.
pointY number The Y coordinate of the point.
wkt string The geometry that you want to reproject.
body object A request object containing the geometries to be reprojected, as well as input and output spatial reference systems.
fromProj string The EPSG/ESRI ID or Proj4 projection string describing the original spatial reference system in which the geometry is expressed. If using a Proj4 string, the value should be URL-encoded.
toProj string The EPSG/ESRI ID or Proj4 projection string describing the target spatial reference system that you want the geometry reprojected to. If using a Proj4 string, the value should be URL-encoded.
callback function the callback for response

projectionClient.projectForPoint(pointY, pointX, fromProj, toProj, callback)

Converts a geometry from one spatial reference system to another.

Syntax

  var callback = function (status, response) {
      console.log(response);
  };
  projectionClient.projectForPoint(-55.0000,31.9000,4326,3857, callback);

Parameters

Name Type Description
pointY number The Y coordinate of the point.
pointX number The X coordinate of the point.
fromProj string The EPSG/ESRI ID or Proj4 projection string describing the original spatial reference system in which the geometry is expressed. If using a Proj4 string, the value should be URL-encoded.
toProj string The EPSG/ESRI ID or Proj4 projection string describing the target spatial reference system that you want the geometry reprojected to. If using a Proj4 string, the value should be URL-encoded.
callback function the callback for response

projectionClient.projectForGeometry(wkt, fromProj, toProj, callback)

Converts geometry in Well Known Text format from one spatial reference system to another.

Syntax

  var callback = function (status, response) {
      console.log(response);
  };
  projectionClient.projectForGeometry('LINESTRING(-1399103.3657318656 308805.5942721125,-802283.0488812095 592539.8432666864)',3857, 4326, callback);

Parameters

Name Type Description
wkt string The geometry that you want to reproject.
fromProj string The EPSG/ESRI ID or Proj4 projection string describing the original spatial reference system in which the geometry is expressed. If using a Proj4 string, the value should be URL-encoded.
toProj string The EPSG/ESRI ID or Proj4 projection string describing the target spatial reference system that you want the geometry reprojected to. If using a Proj4 string, the value should be URL-encoded.
callback function the callback for response

projectionClient.projectForGeometries(options, callback)

Converts a collection of geometries in Well Known Text format from one spatial reference system to another.

Syntax

   var wktArr=[
      "POINT(-997961.8412912609 563188.0244051788)",
      "POINT(-900122.4450862352 484916.5074411584)",
      "POINT(-802283.0488812095 612107.7225076917)"
   ];
   var options = {
      body: {
          wkt: wktArr,
          fromProj: "3857",
          toProj: "4326"
      }
  };
  var callback = function (status, response) {
      console.log(response);
  };
  projectionClient.projectForGeometries(options , callback);

Parameters

Name Type Description
options Options
Name Type Default Description
body object A request object containing the geometries to be reprojected, as well as input and output spatial reference systems.
callback function the callback for response

tg.ReverseGeocodingClient

A class provides the methods to access the ReverseGeocoding APIs. Reverse geocode to find locations near a geometry.

Syntax

  var reverseGeocodingClient = new tg.ReverseGeocodingClient ('Your-Cloud-Service-Api-Key');

Parameters

Name Type Description
apiKey string An API key for access to ThinkGeo Cloud services, it can be created following the guide

Return Value

a ReverseGeocoding object to access the ReverseGeocoding APIs in ThinkGeo Cloud service.

reverseGeocodingClient.search(options, callback)

Searches for locations around a geometry.

Syntax

  var options = {
      pointX: -10780076.527743513,
      pointY: 3864866.351926295,
      srid: 3857,
  };
  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.search(options , callback);

Parameters

Name Type Description
options Options
Name Type Default Description
pointX number The X coordinate of the point.
pointY number The Y coordinate of the point.
wkt string The Well Known Text (WKT) of the geometry to use as the search area.
body array A list of points to be reverse geocoded.
srid integer 4326 The SRID (coordinate system) in which to express the result.
proj4String string The Proj4String (coordinate system) in which to express the result.
searchRadius number 200 The maximun radius around the input point to search for places. Defaults to 200.
searchRadiusUnit string “Meter” The unit of measure in which the SearchRadius is expressed. Defaults to “Meter”.
maxResults integer 20 The maximum number of results to return. Defaults to 20.
locationCategories string “Common” The categories of locations to include in the result set. The default value is “Common”.
locationTypes string Filters the resulting locations by type. Multiple types should be separated by a comma. Defaults to no filter.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
distanceFromQueryFeatureUnit string “Meter” The unit of measure in which the distance is expressed. Defaults to “Meter”.
lang string “en” Optional. Sets the language for the search result. The default value is “en”.
callback function the callback for response

reverseGeocodingClient.searchPlaceByPoint(pointY, pointX, callback, options)

Searches for locations around a geometry.

Syntax

  var options = {
      srid: 3857
  };
  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.searchPlaceByPoint(3864866.351926295, -10780076.527743513, callback, options);

Parameters

Name Type Description
pointY number The Y coordinate of the point.
pointX number The X coordinate of the point.
callback function the callback for response
options Options
Name Type Default Description
srid integer 4326 The SRID (coordinate system) in which to express the result.
proj4String string The Proj4String (coordinate system) in which to express the result.
searchRadius number 200 The maximun radius around the input point to search for places. Defaults to 200.
searchRadiusUnit string “Meter” The unit of measure in which the SearchRadius is expressed. Defaults to “Meter”.
maxResults integer 20 The maximum number of results to return. Defaults to 20.
locationCategories string “Common” The categories of locations to include in the result set. The default value is “Common”.
locationTypes string Filters the resulting locations by type. Multiple types should be separated by a comma. Defaults to no filter.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
distanceFromQueryFeatureUnit string “Meter” The unit of measure in which the distance is expressed. Defaults to “Meter”.
lang string “en” Optional. Sets the language for the search result. The default value is “en”.

reverseGeocodingClient.searchPlaceByLine(wkt, callback, options)

Searches for locations around a line.

Syntax

  var options = {
      srid: 3857,
  };
  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.searchPlaceByLine("LINESTRING(-10780840.898026364 3864952.343583116,-10780219.847171547 3865009.67135433)", callback, options);

Parameters

Name Type Description
wkt string The Well Known Text (WKT) of the geometry to use as the search area.
callback function the callback for response
options Options
Name Type Default Description
srid integer 4326 The SRID (coordinate system) in which to express the result.
proj4String string The Proj4String (coordinate system) in which to express the result.
searchRadius number 200 The maximun radius around the input point to search for places. Defaults to 200.
searchRadiusUnit string “Meter” The unit of measure in which the SearchRadius is expressed. Defaults to “Meter”.
maxResults integer 20 The maximum number of results to return. Defaults to 20.
locationCategories string “Common” The categories of locations to include in the result set. The default value is “Common”.
locationTypes string Filters the resulting locations by type. Multiple types should be separated by a comma. Defaults to no filter.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
distanceFromQueryFeatureUnit string “Meter” The unit of measure in which the distance is expressed. Defaults to “Meter”.
lang string “en” Optional. Sets the language for the search result. The default value is “en”.

reverseGeocodingClient.searchPlaceByArea(wkt, callback, options)

Searches for locations around a geometry.

Syntax

  var wkt= "POLYGON((-10780611.586941509 3864847.242669224,-10780831.343397828 3864617.9315843685,-10780363.166599581 3864637.0408414397,-10780611.586941509 3864847.242669224))"
  var options = {
      srid: 3857,
  };
  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.searchPlaceByArea(wkt, callback, options);

Parameters

Name Type Description
wkt string The Well Known Text (WKT) of the geometry to use as the search area.
callback function the callback for response
options Options
Name Type Default Description
srid integer 4326 The SRID (coordinate system) in which to express the result.
proj4String string The Proj4String (coordinate system) in which to express the result.
searchRadius number 200 The maximun radius around the input point to search for places. Defaults to 200.
searchRadiusUnit string “Meter” The unit of measure in which the SearchRadius is expressed. Defaults to “Meter”.
maxResults integer 20 The maximum number of results to return. Defaults to 20.
locationCategories string “Common” The categories of locations to include in the result set. The default value is “Common”.
locationTypes string Filters the resulting locations by type. Multiple types should be separated by a comma. Defaults to no filter.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
distanceFromQueryFeatureUnit string “Meter” The unit of measure in which the distance is expressed. Defaults to “Meter”.
lang string “en” Optional. Sets the language for the search result. The default value is “en”.

reverseGeocodingClient.searchPlaceByPoints(options, callback)

Searches for locations around multi points.

Syntax

  var options = {
      body:[
          {
             coord: "32.8345,-96.8616",
             srid: 4326
          },
          {
             coord: "34.8345,-93.8616",
             srid: 4326
          }
      ]
  };
  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.searchPlaceByPoints(options , callback);

Parameters

Name Type Description
options Options
Name Type Default Description
body array A list of points to be reverse geocoded.
srid integer 4326 The SRID (coordinate system) in which to express the result.
proj4String string The Proj4String (coordinate system) in which to express the result.
searchRadius number 200 The maximun radius around the input point to search for places. Defaults to 200.
searchRadiusUnit string “Meter” The unit of measure in which the SearchRadius is expressed. Defaults to “Meter”.
maxResults integer 20 The maximum number of results to return. Defaults to 20.
locationCategories string “Common” The categories of locations to include in the result set. The default value is “Common”.
locationTypes string Filters the resulting locations by type. Multiple types should be separated by a comma. Defaults to no filter.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
distanceFromQueryFeatureUnit string “Meter” The unit of measure in which the distance is expressed. Defaults to “Meter”.
lang string “en” Optional. Sets the language for the search result. The default value is “en”.
callback function the callback for response

reverseGeocodingClient.searchPlaceById(placeId, callback, options)

Get details about a place by its OpenStreetMap ID.

Syntax

  var options={
      lang:"en"
  }
  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.searchPlaceById(8689729, callback, options);

Parameters

Name Type Description
placeId integer The OpenStreetMap ID of the place
options Options
Name Type Default Description
lang string “en” Optional. Sets the language for the search result. The default value is “en”.
callback function the callback for response

reverseGeocodingClient.getPlaceCatergories(callback)

Get the available location categories.

Syntax

  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.getPlaceCatergories(callback);

Parameters

Name Type Description
callback function the callback for response

reverseGeocodingClient.getCommonCatergories(callback)

Get the types of locations that are considered common.

Syntax

  var callback = function (status, response) {
      console.log(response);
  };
  reverseGeocodingClient.getCommonCatergories(callback);

Parameters

Name Type Description
callback function the callback for response

tg.GeocodingClient

A class provides the methods to access the GeocodingClient APIs. Geocode to get the coordinates of an address.

Syntax

var geocodingClient = new tg.GeocodingClient ('Your-Cloud-Service-Api-Key');

Parameters

Name Type Description
apiKey string An API key for access to ThinkGeo Cloud services, it can be created following the guide

Return Value

a Geocoding object to access the Geocoding APIs in ThinkGeo Cloud service.

geocodingClient.search(options, callback)

Search for a location expression.

Syntax

  var options = {
       location: "Dallas",
       maxResults: 5,
  };
  var callback = function (status, response) {
      console.log(response);
  };
  geocodingClient.search(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
location array The location expression.
body string A list of addresses to be geocoded.
locationType string Specifies what types of locations will be considered a match. Possible values are Address, Street, State, City, County, Zipcode, Country.
fuzzyMatch boolean false Specifies whether to attempt approximate, as well as exact, matching when performing geocodes. Defaults to false.
maxResults integer 10 The maximum number of possible matches to return, if multiple candidates are found. Defaults to 10.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
srid integer The SRID (coordinate system ID) in which to express the result. Mutually exclusive from the Proj4String parameter.
proj4String string “+proj=longlat +datum=WGS84 +no_defs” The Proj4 projection string (coordinate system) in which to express the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
callback function the callback for response

geocodingClient.searchByPoint(location, callback, options)

Search for a location expression.

Syntax

  var options = {
       maxResults: 5,
  };
  var callback = function (status, response) {
      console.log(response);
  };
  geocodingClient.searchByPoint("Dallas", callback, options);

Parameters

Name Type Description
location string The location expression.
options Options
Name Type Default Description
locationType string Specifies what types of locations will be considered a match. Possible values are Address, Street, State, City, County, Zipcode, Country.
fuzzyMatch boolean false Specifies whether to attempt approximate, as well as exact, matching when performing geocodes. Defaults to false.
maxResults integer 10 The maximum number of possible matches to return, if multiple candidates are found. Defaults to 10.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
srid integer The SRID (coordinate system ID) in which to express the result. Mutually exclusive from the Proj4String parameter.
proj4String string “+proj=longlat +datum=WGS84 +no_defs” The Proj4 projection string (coordinate system) in which to express the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
callback function the callback for response

geocodingClient.searchBatch(options, callback)

Search for a location expression

Syntax

  var options = {
       body:[
           {
              searchText:"Dallas",
              maxResults:5
           },
           {
              searchText:"Frisco"
           }
       ]
       maxResults: 6,
  };
  var callback = function (status, response) {
      console.log(response);
  };
  geocodingClient.searchBatch(options, callback);

Parameters

Name Type Description
options Options
Name Type Default Description
body string A list of addresses to be geocoded.
locationType string Specifies what types of locations will be considered a match. Possible values are Address, Street, State, City, County, Zipcode, Country.
fuzzyMatch boolean false Specifies whether to attempt approximate, as well as exact, matching when performing geocodes. Defaults to false.
maxResults integer 10 The maximum number of possible matches to return, if multiple candidates are found. Defaults to 10.
verboseResults boolean false Indicates whether the results should be verbose or not. When false, the results will have fewer properties. Defaults to false.
srid integer The SRID (coordinate system ID) in which to express the result. Mutually exclusive from the Proj4String parameter.
proj4String string “+proj=longlat +datum=WGS84 +no_defs” The Proj4 projection string (coordinate system) in which to express the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
callback function the callback for response

tg.BaseClient

A class provides the basic methods to send request to ThinkGeo Cloud services. Subclasses: ColorClient, Elevation, GeocodingClient, MapsClient, ProjectionClient, ReverseGeocodingClient.

on

  • sendingrequest
  • sentrequest
// For example elevationClient
elevationClient.on("sendingrequest", function (e){
    console.log(e);
});
elevationClient.on("sentrequest", function (e){
    console.log(e);
})
thinkgeo_cloud_javascript_client_apis.1550260682.txt.gz · Last modified: 2019/02/15 19:58 by benbai