The FeatureService class provides methods to query Spatial Server tables for features.
Search results are returned as GeoJSON FeatureCollections.
The search call is performed asynchronously and is handled by a Dojo deferred object.
Callers must register callbacks with the deferred object using addCallback(...) to handle the
returned results and, optionally, addErrback(...) to handle any errors returned.
For example:
function doSearch() {
...
var deferredResult = featureSearch.searchAtPoint(point, srs, tableparam);
deferredResult.addCallback(handleResults);
deferredResult.addErrback(handleError);
}
function handleResults(output) {
if (output.features) {
...
}
}
function handleError(error) {
...
}
Please note that due to the lack of built-in support for arbitrary-precision numeric values in JavaScript, numeric literals sent by the Spatial Server REST API will be rounded to the nearest double value, if necessary.
| Method Attributes | Method Name and Description |
|---|---|
|
searchAtPoint(point, srs, table)
Searches for features at a given geographic location.
|
|
|
searchById(tableName, attributes, id, destinationSrs)
Searches for features on a table based on the Id.
|
|
|
searchBySQL(query)
Searches for features on a table using an SQL query.
|
|
|
searchNearest(parameters)
Search for features nearby a given geometry.
|
point100 m, or 20 mi. Supported unit valus
are ft, km, m, mi, and nm.For example:
var query = "SELECT * FROM \"/NamedTables/UKCTY215\" WHERE Place_Name = 'LONDON' OR Place_Name = 'Liverpool'"; var deferredResult = featureSearch.searchBySQL(query);
100
m, or 20 mi. Supported distance units are ft,
km, m, mi, and nm. Optional.withinDistance attribute or defaults
to mi if withinDistance is not
specified. Optional.