User Tools

Site Tools


thinkgeo_cloud_javascript_client_apis

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.RoutingClient

A class provides the methods to access the Routing APIs. Get turn-by-turn driving directions, define service areas that can be reached by car in a given time or distance, and more.

Syntax

var routingClient = new tg.RoutingClient ('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 Routing object to access the Routing APIs in ThinkGeo Cloud service.

routingClient.getRoute(waypoints, callback, options)

Get a route through the specified waypoints.

Syntax

  var waypoints = [{
    x: -96.872893,
    y: 33.184352
  },{
    x: -83.441568,
    y: 42.404719
  }];
  var options = {
       srid: 4326,
       turnByTurn: true,
       distanceUnit: 'Meter',
       durationUnit: 'Minute'
  };
  var callback = function (status, response) {
      console.log(response);
  };
  routingClient.getRoute(waypoints, callback, options);

Parameters

Name Type Description
waypoints array A list of coordinates to travel in order.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
turnByTurn boolean false Whether to return turn-by-turn instructions or not. Defaults to false.
coordinateSnapRadius double 5000 The maximum distance of a coordinate can be snapped to the road network. Defaults to 5000 meters.
coordinateSnapRadiusUnit string meter The unit of the radius to snap the input coordinate to road network.
distanceUnit string meter The unit of measure in which to express the length of the route. Default to Meter.
durationUnit string minute The unit of the time in which to express the duration of the route.

routingClient.getServiceArea(pointY, pointX, serviceLimits, callback, options)

Get the reachable service area (isochrones) for a coordinate point, based on the specified time or distance constraints.

Syntax

  var serviceLimits = [10, 30, 60];
  var callback = function (status, response) {
    console.log(response);
  };
  var options = {
    srid = 3857,
    serviceLimitsType = 'Time',
    durationUnit = 'minute',
    distanceUnit = 'meter'
  };
  routingClient.getServiceArea(33.184352, -96.872893, serviceLimits, callback, options);

Parameters

Name Type Description
pointY double The Y coordinate of the point.
pointX double The X coordinate of the point.
serviceLimits array The list represents the travel distances or travel times to generate for each facility. The maximum number of serviceLimits is 6.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
contourGranularity double 1.0 A float in the range of (0, 1.0) to identify how much we want to remove the contours. 0 means do not remove any contour at all, 1.0 means only return the largest contour.
coordinateSnapRadius double 5000 The maximum distance of a coordinate can be snapped to the road network.
coordinateSnapRadiusUnit string meter The unit of the radius to snap the input coordinate to road network.
distanceUnit string meter The unit of measure in which to express the length of route.
durationUnit string minute The unit of the time in which to express the duration of traveling the route.
gridSizeInMeters double 400 A float value in meters used as the tolerance for concave polygon. The smaller of the number is getting more accurate of the service areas but slower performance, better a value bigger than 300, but depends on the size of the result coverage.
serviceAreaSeparationType string separated Specify whether to include the region covered by the smaller service area into the region covered by the larger service area.
serviceAreaType string polygon Indicates whether the result is returned as polygons enveloping the accessible roads, or as linestrings surrounding those roads.
serviceLimitsType string time Indicates the unit of the serviceLimits.
travelDirection string from Indicates the direction of travel to or from the coordinates.

tg.MapsQueryClient

A class provides the methods to access the Maps Query APIs. Perform spatial query against each types of data.

Syntax

var mapsQueryClient = new tg.MapsQueryClient ('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 Maps Query object to access the Maps Query APIs in ThinkGeo Cloud service.

mapsQueryClient.getFeaturesWithin(queryLayer, wkt, callback, options)

Get the features that are within the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POLYGON((15.609372854233 56.62500500679, 1.8984353542334 42.56250500679, 30.023435354233 41.15625500679, 15.609372854233 56.62500500679))';
  var options = {
       srid: 4326,
       maxResults: 100,
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesWithin(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesContaining(queryLayer, wkt, callback, options)

Get the features that contain the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POINT(-95.484377145767 36.93750500679)';
  var options = {
       srid: 4326,
       maxResults: 100,
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesContaining(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesIntersecting(queryLayer, wkt, callback, options)

Get the features that intersect the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POLYGON((15.609372854233 56.62500500679, 1.8984353542334 42.56250500679, 30.023435354233 41.15625500679, 15.609372854233 56.62500500679))';
  var options = {
       srid: 4326,
       maxResults: 100,
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesIntersecting(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesOverlapping(queryLayer, wkt, callback, options)

Get the features that overlap the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POLYGON((15.609372854233 56.62500500679, 1.8984353542334 42.56250500679, 30.023435354233 41.15625500679, 15.609372854233 56.62500500679))';
  var options = {
       srid: 4326,
       maxResults: 100,
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesOverlapping(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesTouching(queryLayer, wkt, callback, options)

Get the features that touch the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POLYGON((7595881.1058614058 -585345.10944436956,7595881.1058614058 2704373.8120167661,-3939883.7747361474 2704373.8120167661,-3939883.7747361474 -585345.10944436956,7595881.1058614058 -585345.10944436956))';
  var options = {
       srid: 3857,
       maxResults: 100,
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesTouching(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesNearest(queryLayer, wkt, callback, options)

Get the features that are nearest to the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POINT(17.367185354233 47.83594250679)';
  var options = {
       srid: 4326,
       maxResults: 100,
       searchRadius: 200,
       searchRadiusUnit: 'Kilometer',
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesNearest(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
searchRadius double The radius of the search area around the target geometry. If not specified, it's assumed that there is no limit.
searchRadiusUnit string The unit of measure in which the searchRadius is expressed.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesWithinDistance(queryLayer, wkt, callback, options)

Get the features that are within a certain distance of the target shape.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POINT(17.367185354233 47.83594250679)';
  var options = {
       srid: 4326,
       maxResults: 100,
       distance: 200,
       distanceUnit: 'Kilometer',
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesWithinDistance(queryLayer, wkt, callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
distance double 200 The distance within which to find features.
distanceUnit string “Meter” The unit of measure in which the distance is expressed.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

mapsQueryClient.getFeaturesCustom(queryLayer, wkt, callback, options)

Perform a custom spatial query, using the specified query layer, spatial relationship type, and query feature.

Syntax

  var queryLayer = 'countries';
  var wkt = 'POLYGON((15.609372854233 56.62500500679, 1.8984353542334 42.56250500679, 30.023435354233 41.15625500679, 15.609372854233 56.62500500679))';
  var options = {
       srid: 4326,
       maxResults: 100,
       returnFeatureAttributes: true,
       featureAttributesToReturn: ['id', 'name']
  };
  var callback = function (status, response) {
      console.log(response);
  };
  mapsQueryClient.getFeaturesCustom(queryLayer, wkt, 'within', callback, options);

Parameters

Name Type Description
queryLayer string The query layer.
wkt string The well-known text of target shape.
callback function the callback for response.
options Options
Name Type Default Description
srid integer The SRID (coordinate system ID) in which to input and output 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 input and output the result. Mutually exclusive from the Srid parameter. Defaults to “+proj=longlat +datum=WGS84 +no_defs”.
distance double 200 The distance within which to find features.
distanceUnit string “Meter” The unit of measure in which the distance is expressed.
searchRadius double The radius of the search area around the target geometry. If not specified, it's assumed that there is no limit.
searchRadiusUnit string The unit of measure in which the searchRadius is expressed.
maxResults integer 100 The maximum number of features to return.
returnFeatureAttributes boolean true If true, specifies that the feature attribute column names and values will be returned in the response.
featureAttributesToReturn array If returnFeatureAttributes is true, this allows the user to specify which a specific subset of attributes to be returned.

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.txt · Last modified: 2019/07/17 03:26 by kevinwan