OpenSpace.SupportService

Queries the API support service for items such as tile usage counts.

Example

The following example shows how to add the support service to the map:

var osMap, screenOverlay, supportService;

function init()
{
  osMap = new OpenSpace.Map('map');

  // Add a screen Overlay
  screenOverlay = new OpenSpace.Layer.ScreenOverlay("tilecount");
  screenOverlay.setPosition(new OpenLayers.Pixel(10, 480));
  osMap.addLayer(screenOverlay);

  osMap.setCenter(new OpenSpace.MapPoint(438760,114760), 8);

  // Create a new service
  supportService = new OpenSpace.SupportService();

  // Register to query service when map is moved
  osMap.events.register("moveend", osMap, function(e) {
            supportService.getTileCount(results);
  });
}

function results(tilesUsed, maxTiles)
{
  // Draw results on screen in overlay
  screenOverlay.setHTML("<DIV style=\"width: 250px; height=75px; color: white; background-color: gray; font-size: 20px\">" +
                        "Tiles Used: " + tilesUsed + " of " + maxTiles + " </DIV>");
}
Summary
OpenSpace.SupportServiceQueries the API support service for items such as tile usage counts.
Constructor
OpenSpace.SupportServiceCreate a new OpenSpace.SupportService instance
Functions
getTileCountSends a query to the support server to find out the current map tile usage and the maximum number of available tiles.
getGazetteerCountSends a query to the support server to find out the current gazetteer usage and the maximum number of available requests.
getPostcodeCountSends a query to the support server to find out the current postcode usage and the maximum number of available requests.
getBoundaryCountSends a query to the support server to find out the current boundary usage and the maximum number of available requests.
_doServiceQuerySets up and calls a JSON request to the support server.
_getTileCountCallbackCalls the given callback function with the results of the query.
_getGazetteerCountCallbackCalls the given callback function with the results of the query.
_getPostcodeCountCallbackCalls the given callback function with the results of the query.
_getBoundaryCountCallbackCalls the given callback function with the results of the query.

Constructor

OpenSpace.SupportService

Create a new OpenSpace.SupportService instance

Parameters

Returns

An instance of OpenSpace.SupportService

Functions

getTileCount

getTileCount: function(callback)

Sends a query to the support server to find out the current map tile usage and the maximum number of available tiles.

Parameters

callback{Function} A function to call with the result.

Returns

{tilesUsed, maxTiles} Calls the callback function with the number of tiles used by this API key and the maximum number available.

getGazetteerCount

getGazetteerCount: function(callback)

Sends a query to the support server to find out the current gazetteer usage and the maximum number of available requests.

Parameters

callback{Function} A function to call with the result.

Returns

{gazetteerCount, maxRequests} Calls the callback function with the number of gazetteer requests made by this API key and the maximum number of requests available.

getPostcodeCount

getPostcodeCount: function(callback)

Sends a query to the support server to find out the current postcode usage and the maximum number of available requests.

Parameters

callback{Function} A function to call with the result.

Returns

{postcodeCount, maxRequests} Calls the callback function with the number of postcode requests made by this API key and the maximum number of requests available.

getBoundaryCount

getBoundaryCount: function(callback)

Sends a query to the support server to find out the current boundary usage and the maximum number of available requests.

Parameters

callback{Function} A function to call with the result.

Returns

{boundaryCount, maxRequests} Calls the callback function with the number of boundary requests made by this API key and the maximum number of requests available.

_doServiceQuery

_doServiceQuery: function(query,
callback)

Sets up and calls a JSON request to the support server.

Parameters

query{String} The specific query to ask to support service.
callback{Function} A function to call with the results.

Returns

{JSON} JSON data containing details of the results of this query.

_getTileCountCallback

_getTileCountCallback: function(jsonData)

Calls the given callback function with the results of the query.

Parameters

jsonData{String} JSON data containing details of the results of this query.

_getGazetteerCountCallback

_getGazetteerCountCallback: function(jsonData)

Calls the given callback function with the results of the query.

Parameters

jsonData{String} JSON data containing details of the results of this query.

_getPostcodeCountCallback

_getPostcodeCountCallback: function(jsonData)

Calls the given callback function with the results of the query.

Parameters

jsonData{String} JSON data containing details of the results of this query.

_getBoundaryCountCallback

_getBoundaryCountCallback: function(jsonData)

Calls the given callback function with the results of the query.

Parameters

jsonData{String} JSON data containing details of the results of this query.
getTileCount: function(callback)
Sends a query to the support server to find out the current map tile usage and the maximum number of available tiles.
getGazetteerCount: function(callback)
Sends a query to the support server to find out the current gazetteer usage and the maximum number of available requests.
getPostcodeCount: function(callback)
Sends a query to the support server to find out the current postcode usage and the maximum number of available requests.
getBoundaryCount: function(callback)
Sends a query to the support server to find out the current boundary usage and the maximum number of available requests.
_doServiceQuery: function(query,
callback)
Sets up and calls a JSON request to the support server.
_getTileCountCallback: function(jsonData)
Calls the given callback function with the results of the query.
_getGazetteerCountCallback: function(jsonData)
Calls the given callback function with the results of the query.
_getPostcodeCountCallback: function(jsonData)
Calls the given callback function with the results of the query.
_getBoundaryCountCallback: function(jsonData)
Calls the given callback function with the results of the query.
Close