ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
This is an old revision of the document!
The ThinkGeo Cloud JavaScript SDK Quickstart Guide will guide you through the process of creating a sample in any web page and will help you become familiar with ThinkGeo Cloud JavaScript SDK.
The purpose of this guide is to help you quickly get started building your own spatially aware web page with ThinkGeo Cloud. Like any new software, there is some learning to be done along the way.
How do we start to learn how to take advantage of the power of ThinkGeo Cloud? The best way is to make a sample application with it.
Let's start with a new web page. Below you'll find a complete working example. Create a new file, copy in the contents below, and open in a browser:
<!doctype html> <html lang="en"> <head> <!-- latest minified version of thinkgeocloudclient.js --> <script src="https://cdn.thinkgeo.com/cloudclient-js/1.0.0/thinkgeocloudclient.js"></script> <title>Cloud Service Sample</title> </head> <body> <h2>My Cloud Service Sample</h2> <div id="response"></div> <script type="text/javascript"> var reverseGeocodingClient = new tg.ReverseGeocodingClient('Yy6h5V0QY4ua3VjqdkJl7KTXpxbKgGlFJWjMTGLc_8s~'); // Find the ThinkGeo office address by coordinate reverseGeocodingClient.searchPlaceByPoint(33.128367, -96.809847, function (status, response) { if (response.data.bestMatchLocation) { let address = response.data.bestMatchLocation.data.address; document.getElementById('response').innerHTML = address; } }) </script> </body> </html>
To use ThinkGeoCloudClient-js in a web page you will need 3 things:
<!-- latest minified version of thinkgeocloudclient.js --> <script src="https://cdn.thinkgeo.com/cloudclient-js/1.0.0/thinkgeocloudclient.js"></script>
Create a ReverseGeocodingClient object with Your-Cloud-Service-Api-Key.
var reverseGeocodingClient = new tg.ReverseGeocodingClient('Yy6h5V0QY4ua3VjqdkJl7KTXpxbKgGlFJWjMTGLc_8s~');
The 'searchPlaceByPoint' is an API to searche for locations around a point. The default projection is 'EPSG:4326'.
reverseGeocodingClient.searchPlaceByPoint(33.128367, -96.809847, function (status, response){ });
parameters:
Add a div to attach the response.
<div id="response"></div>
Attach the response to div in callback
function (status, response){ if (response.data.bestMatchLocation) { let address = response.data.bestMatchLocation.data.address; document.getElementById('response').innerHTML = address; } }
After include ThinkGeoCloudClient.js, you can find there is a namespace tg short for ThinkGeo. Currently, there are 6 Client Classes in tg: