new ThemeServer(options)
service/igs/ThemeServer/ThemeServer.js, line 16
专题图服务
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
Object |
构造参数
|
Example
// ES5引入方式
const { ThemeServer } = zondy.service
// ES6引入方式
import { ThemeServer } from "@mapgis/webclient-common"
const themeServer = new ThemeServer({
url: 'http://192.168.82.89:6163/igs/rest/theme/Hubei4326'
});
Extends
Members
-
clientIdBoolean
-
客户端id
-
enableGlobeFetchBoolean
-
是否使用确据唯一的fetch对象,默认为true,当设为false时,会使用自己私有的fetch对象,所有的请求设置不会影响全局
Example
//设置请求基地址 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //请求基地址 url: '你的URL', //使用私有的fetch对象 enableGlobeFetch: false, //此时设置token等属性,不会影响全局的fetch对象 tokenValue: '你的token' }); //继续使用全局fetch BaseServer.enableGlobeFetch = true; -
headersString
-
请求头参数
Example
//设置请求头参数 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //请求头 headers: { //设置Content-Type为multipart/form-data 'Content-Type': 'multipart/form-data', //设置token 'token': '你的token' } }); //动态修改 BaseServer.headers.token = '新token'; -
requestInterceptorfunction
-
请求发送拦截器
Example
//设置拦截器,任何一个继承自BaseServer的对象都可以设置,全局唯一 // ES5引入方式 const { BaseServer,RequestInterceptor } = zondy.service // ES6引入方式 import { BaseServer,RequestInterceptor } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //设置请求发送拦截器 requestInterceptor: new RequestInterceptor({ //请求发送前进行统一处理 before: function(config) { //执行你的业务逻辑 //注意必须显示返回config对象,如果返回为空,则不发送请求 return config; }, //请求发送失败时进行统一处理 failure: function(error) { //执行你的业务逻辑 } }) }); //动态修改 BaseServer.requestInterceptor.before = function() {}; -
requestTimeoutString
-
请求超时时间,默认45000ms,即45s
Example
//设置超时时间 //初始化AddressServer服务对象 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //超时时间 requestTimeout: 2000 }); //动态修改 BaseServer.requestTimeout = 3000; -
responseInterceptorfunction
-
请求响应拦截器
Example
//设置拦截器,任何一个继承自BaseServer的对象都可以设置,全局唯一 // ES5引入方式 const { BaseServer,ResponseInterceptor } = zondy.service // ES6引入方式 import { BaseServer,ResponseInterceptor } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //设置请求响应拦截器 responseInterceptor: new ResponseInterceptor({ //执行请求响应,接口调用成功时会执行的回调 success: function(result) { //执行你的业务逻辑 //注意必须显示返回result对象,如果返回为空,则不执行请求响应成功回调 return result; }, //请求响应成功,接口调用失败时会执行的函数 failure: function(result) { //执行你的业务逻辑 //注意必须显示返回result对象,如果返回为空,则不执行回调韩式 return result; } }) }); //动态修改 BaseServer.responseInterceptor.success = function() {}; -
tokenAttachTypeTokenAttachType
-
指定token附加到何处
Example
//设置token值 // ES5引入方式 const { BaseServer } = zondy.service const { TokenAttachType } = zondy.enum // ES6引入方式 import { BaseServer,TokenAttachType } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //token名 tokenKey: '你的token key', //token值 tokenValue: '你的token值', //指定token附加到url后面 tokenAttachType: TokenAttachType.url }); //动态修改 BaseServer.tokenAttachType = TokenAttachType.header; -
tokenKeyString
-
token名
Example
//设置token名 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //token名 tokenKey: '你的tokenKey' }); //动态修改 BaseServer.tokenKey = '新tokenKey'; -
tokenValueString
-
token值
Example
//设置token值 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //token值 tokenValue: '你的token值' }); //动态修改 BaseServer.tokenValue = '新token值'; -
urlString
-
服务基地址
Example
//设置请求基地址 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //请求基地址 url: '你的URL' }); //动态修改 BaseServer.url = '新URL';
Methods
-
addTheme(options)
service/igs/ThemeServer/ThemeServer.js, line 380 -
添加专题图
Name Type Description optionsObject 查询参数
Name Type Description idxArrString 可选 专题图索引(索引从0开始,例如:"0,1,2/0,0,0"):图层索引/专题图索引,必填
themeInfoArrayArray 可选 专题图参数,必填
successfunction 可选 查询成功回调
failurefunction 可选 查询失败回调
Example
//回调方式 // ES5引入方式 const { Theme } = zondy.object // ES6引入方式 import { Theme } from "@mapgis/webclient-common" //专题图信息数组 var themesInfoArr = []; //初始化Zondy.Object.Theme.ThemesInfo,用于设置需添加的专题相关信息 themesInfoArr[0] = new Theme.ThemesInfo(); //初始化指定图层的专题图信息对象,之后再给该数组赋值 themesInfoArr[0].LayerName = "湖北省市级区划2"; themesInfoArr[0].ThemeArr = []; //实例化CMultiClassTheme类 themesInfoArr[0].ThemeArr[0] = new Theme.CRangeTheme(); themesInfoArr[0].ThemeArr[0].Name = "分段专题图"; //指定为分段专题图 themesInfoArr[0].ThemeArr[0].IsBaseTheme = false; themesInfoArr[0].ThemeArr[0].Visible = true; themesInfoArr[0].ThemeArr[0].GeoInfoType = "Reg"; //未分段值的图形信息设置 themesInfoArr[0].ThemeArr[0].DefaultInfo = new Theme.CThemeInfo(); themesInfoArr[0].ThemeArr[0].DefaultInfo.Caption = "未分类"; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo = new Theme.CRegInfo(); themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.Ovprnt = true; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.Angle = 0; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.EndClr = 0; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.FillClr = 17; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.FillMode = 0; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.FullPatFlg = true; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.PatClr = 45; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.PatHeight = 5; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.PatWidth = 5; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.PatID = 0; themesInfoArr[0].ThemeArr[0].DefaultInfo.RegInfo.OutPenW = 1; //分段取值设置 themesInfoArr[0].ThemeArr[0].Expression = "GDP2016"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr = []; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0] = new Theme.CRangeThemeInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0].StartValue = "0"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0].EndValue = "100"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0].RegInfo = new Theme.CRegInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0].RegInfo.FillClr = 110; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1] = new Theme.CRangeThemeInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1].StartValue = "100"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1].EndValue = "150"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1].RegInfo = new Theme.CRegInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1].RegInfo.FillClr = 26; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2] = new Theme.CRangeThemeInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2].StartValue = "150"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2].EndValue = "200"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2].RegInfo = new Theme.CRegInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2].RegInfo.FillClr = 22; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3] = new Theme.CRangeThemeInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3].StartValue = "200"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3].EndValue = "400"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3].RegInfo = new Theme.CRegInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3].RegInfo.FillClr = 16; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4] = new Theme.CRangeThemeInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4].StartValue = "400"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4].EndValue = "6000"; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4].RegInfo = new Theme.CRegInfo(); themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4].RegInfo.FillClr = 11; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0].RegInfo.FillClr = 110; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1].RegInfo.FillClr = 26; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2].RegInfo.FillClr = 22; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3].RegInfo.FillClr = 16; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4].RegInfo.FillClr = 11; themeServer.addTheme({ idxArr: '1/0', themeInfoArray: themesInfoArr, success: function (result) { console.log('请求成功:', result); }, failure: function (result) { console.log('请求失败:', result); } }); //promise方式 themeServer.addTheme({ idxArr: '1/0', themeInfoArray: themesInfoArr }).then(function (result) { console.log('请求成功:', result); }).catch(function (result) { console.log('请求失败:', result); }); -
deleteTheme(options)
service/igs/ThemeServer/ThemeServer.js, line 179 -
删除专题图
Name Type Description optionsObject 查询参数
Name Type Description idxArrString 可选 专题图索引(索引从0开始,例如:"0,1,2/0,0,0"):图层索引/专题图索引,必填
successfunction 可选 查询成功回调
failurefunction 可选 查询失败回调
Example
// 回调方式 themeServer.deleteTheme({ idxArr: '1/0', success: function (result) { console.log('请求成功:', result); }, failure: function (result) { console.log('请求失败:', result); } }); // promise方式 themeServer.deleteTheme({ idxArr: '1/0' }).then(function (result) { console.log('请求成功:', result); }).catch(function (result) { console.log('请求失败:', result); }); -
formatThemInfo(jsonObj)
service/igs/ThemeServer/ThemeServer.js, line 49 -
解析专题图信息
Name Type Description jsonObjObject 专题图信息Json对象
-
inherited queryServerInfo(options)
service/BaseServer.js, line 151 -
获取服务信息,IGS2.0新增服务
Name Type Description options查询参数
Name Type Default Description successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Examples
获取服务信息-回调方式
server.queryServerInfo({ success: function (result) { console.log('请求成功:', result); }, failure: function (result) { console.log('请求失败:', result); } });获取服务信息-promise方式
server.queryServerInfo({ }) .then(function (result) { console.log('请求成功:', result); }).catch(function (result) { console.log('请求失败:', result); }); -
queryThemeInfo(options)
service/igs/ThemeServer/ThemeServer.js, line 136 -
查询专题图参数
Name Type Description optionsObject 查询参数
Name Type Description idxArrString 可选 专题图索引(索引从0开始,例如:"0,1,2/0,0,0"):图层索引/专题图索引,必填
successfunction 可选 查询成功回调
failurefunction 可选 查询失败回调
Example
// 回调方式 themeServer.queryThemeInfo({ idxArr: '1/0', success: function (result) { console.log('请求成功:', result); } }); // promise方式 themeServer.queryThemeInfo({ idxArr: '1/0' }).then(function (result) { console.log('请求成功:', result); }).catch(function (result) { console.log('请求失败:', result); }) -
updateThemesInfo(options)
service/igs/ThemeServer/ThemeServer.js, line 232 -
更新专题图
Name Type Description optionsObject 查询参数
Name Type Description idxArrString 可选 专题图索引(索引从0开始,例如:"0,1,2/0,0,0"):图层索引/专题图索引,必填
themeInfoArrayArray 可选 专题图参数,必填
successfunction 可选 查询成功回调
failurefunction 可选 查询失败回调
Example
// 回调方式 // 更新专题图 themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[0].RegInfo.FillClr = 11; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[1].RegInfo.FillClr = 16; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[2].RegInfo.FillClr = 22; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[3].RegInfo.FillClr = 26; themesInfoArr[0].ThemeArr[0].RangeThemeInfoArr[4].RegInfo.FillClr = 110; themeServer.updateThemesInfo({ idxArr: '1/0', themeInfoArray: themesInfoArr, success: function (result) { console.log('请求成功:', result); }, failure: function (result) { console.log('请求失败:', result); } }); // promise方式 themeServer.updateThemesInfo({ idxArr: '1/0', themeInfoArray: themesInfoArr }).then(function (result) { console.log('请求成功:', result); }).catch(function (result) { console.log('请求失败:', result); })