Class: QueryBySQLService

SuperMap.QueryBySQLService

SQL 查询服务类。在一个或多个指定的图层上查询符合 SQL 条件的空间地物信息。

new SuperMap.QueryBySQLService(url, options)

common/iServer/QueryBySQLService.js, line 9
Name Type Description
url string

服务的访问地址。如访问World Map服务,只需将url设为: http://localhost:8090/iserver/services/map-world/rest/maps/World+Map 即可。

options Object

参数。

Name Type Default Description
eventListeners Object

事件监听器对象。有processCompleted属性可传入处理完成后的回调函数。processFailed属性传入处理失败后的回调函数。

serverType SuperMap.ServerType SuperMap.ServerType.ISERVER 可选

服务器类型,ISERVER|IPORTAL|ONLINE。

format SuperMap.DataFormat SuperMap.DataFormat.GEOJSON 可选

查询结果返回格式,目前支持 iServerJSON 和 GeoJSON 两种格式。参数格式为 "ISERVER","GEOJSON"。

crossOrigin boolean 可选

是否允许跨域请求。

headers Object 可选

请求头。

Example
var queryParam = new SuperMap.FilterParameter({
    name: "Countries@World.1",
    attributeFilter: "Pop_1994>1000000000 and SmArea>900"
});
var queryBySQLParams = new SuperMap.QueryBySQLParameters({
    queryParams: [queryParam]
});
var myQueryBySQLService = new SuperMap.QueryBySQLService(url, {eventListeners: {
    "processCompleted": queryCompleted,
    "processFailed": queryError
	   }
});
queryBySQLService.processAsync(queryBySQLParams);
function queryCompleted(object){//todo};
function queryError(object){//todo};

Extends

Members

formatstring

查询结果返回格式,目前支持iServerJSON 和GeoJSON两种格式。参数格式为"ISERVER","GEOJSON"。

returnContentboolean

是否立即返回新创建资源的表述还是返回新资源的URI。

Methods

inherited ajaxPolling()

common/iServer/CommonServiceBase.js, line 247

请求失败后,如果剩余请求失败次数不为 0,重新获取 URL 发送请求

inherited calculatePollingTimes()

common/iServer/CommonServiceBase.js, line 265

计算剩余请求失败执行次数。

constructor(url, options)

common/iServer/QueryBySQLService.js, line 40

SQL 查询服务类构造函数。

Name Type Description
url string

服务的访问地址。如访问World Map服务,只需将url设为: http://localhost:8090/iserver/services/map-world/rest/maps/World+Map 即可。

options Object

参数。

Name Type Description
eventListeners Object

需要被注册的监听器对象。

inherited destroy()

common/iServer/QueryService.js, line 83

释放资源,将引用资源的属性置空。

inherited getCredential(url){SuperMap.Credential}

common/iServer/CommonServiceBase.js, line 189

获取凭据信息

Name Type Description
url string

服务地址。

Returns:
Type Description
SuperMap.Credential 凭据信息对象。

getJsonParameters(params){Object}

common/iServer/QueryBySQLService.js, line 59

将查询参数转化为 JSON 字符串。 在本类中重写此方法,可以实现不同种类的查询(sql, geometry, distance, bounds等)。

Name Type Description
params SuperMap.QueryBySQLParameters

SQL 查询参数类。

Returns:
Type Description
Object 转化后的 JSON 字符串。

inherited getQueryParameters(params){SuperMap.QueryParameters}

common/iServer/QueryService.js, line 158

将 JSON 对象表示的查询参数转化为 QueryParameters 对象。

Name Type Description
params Object

JSON 字符串表示的查询参数。

Returns:
Type Description
SuperMap.QueryParameters 返回转化后的 QueryParameters 对象。

inherited getUrlCompleted(result)

common/iServer/CommonServiceBase.js, line 220

请求成功后执行此方法。

Name Type Description
result Object

服务器返回的结果对象。

inherited getUrlFailed(result)

common/iServer/CommonServiceBase.js, line 231

请求失败后执行此方法。

Name Type Description
result Object

服务器返回的结果对象。

inherited isServiceSupportPolling()

common/iServer/CommonServiceBase.js, line 292

判断服务是否支持轮询。

inherited processAsync(params)

common/iServer/QueryService.js, line 94

负责将客户端的查询参数传递到服务端。

Name Type Description
params SuperMap.QueryParameters

查询参数。

inherited request(options)

common/iServer/CommonServiceBase.js, line 149
Name Type Description
options Object

参数。

Name Type Default Description
method string 'GET' 可选

请求方式,包括 "GET","POST","PUT","DELETE"。

url string 可选

发送请求的地址。

params Object 可选

作为查询字符串添加到 URL 中的一组键值对,此参数只适用于 GET 方式发送的请求。

data string 可选

发送到服务器的数据。

success function

请求成功后的回调函数。

failure function

请求失败后的回调函数。

scope Object 可选

如果回调函数是对象的一个公共方法,设定该对象的范围。

isInTheSameDomain boolean 可选

请求是否在当前域中。

withCredentials boolean false 可选

请求是否携带 cookie。

crossOrigin boolean 可选

是否允许跨域请求。

headers Object 可选

请求头。

inherited serviceProcessCompleted(result)

common/iServer/QueryService.js, line 128

查询完成,执行此方法。

Name Type Description
result Object

服务器返回的结果对象。

inherited serviceProcessFailed(result)

common/iServer/CommonServiceBase.js, line 316

状态失败,执行此方法。

Name Type Description
result Object

服务器返回的结果对象。