|
After registration you receive an API key which can be used to include the Javascript API into your HTML page as follows: <script type="text/javascript" src="http://topocoding.com/api/getapi_v1.php?key=BGMCCPGOZNKXPZC"></script> The API contains the following functions: topoToFeets( meters ) - conversion from meters to feets topoParseAngle( string ) - converts the combined form of latitude or longitude (e.g. 50°24'37.22"N ) to real number topoGetAltitude( lat, lon, action, context, timeout ) - sends a query to the server to find the altitude of the place with GPS coordinates (lat,lon). When the server responds the event "action" is called with the altitude as a parameter. Context is an optional parameter - if specified, it is passed to "action" as a second parameter. The use of context might help you to avoid memory leaks from Javascript closures. Timeout is an optional parameter, it specifies the maximum time in miliseconds that the client waits for server response. When the timeout expires, the "action" event is called with altitude parameter set to null. If timeout is not specified, the "action" might not be called at all. topoGetAltitudes( quadruples, timeout ) - sends multiple queries at once. "Quadruples" is an array, each element of this array contains latitude, longitude, action and - optionally - context. See the description of topoGetAltitude() parameters. The quadruples are split into groups of at most 280, each group is sent as one request. topoComputeDistance( lat1, lon1, lat2, lon2 ) - computes the shortest distance in km between a place with GPS coordinates (lat1,lon1) and a place with GPS coordinates (lat2,lon2). The computation is performed on client side, the curvature of geoid is considered,. topoComputeIntermediate( lat1, lon1, lat2, lon2 , fraction ) - returns an array containing the coordinates of a place which lies on the shortest path between a place with GPS coordinates (lat1,lon1) and a place with GPS coordinates (lat2,lon2). The ratio determines the exact position of the resulting place, for example 0.5 means the middle. The computation is performed on client side, the curvature of geoid is considered,. topoDrawGraph( divElement, coordinates, width, height, english ) - draws an altitude profile of a path connecting places with given coordinates. "DivElement" refers to an HTML element of type "DIV", which is used as a placeholder for created PNG image. Optional parameters width and height specify the size of image, the default size is 600x250. NEW: english is an optional flag that switches units from meters+kilometers to feets+miles topoResampleCoordinates( points ) - returns the array of points constructed by extending the path with intermediate points. To get better understanding of these API functions, please open the source code of the following example: http://www.topocoding.com/demo/google.html
|