Skip to content

Commit 5b7d8ee

Browse files
committed
Core,leaflet新增专题图服务,并添加example
1 parent f7ad798 commit 5b7d8ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4484
-4
lines changed

build/deps.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var deps = {
3232
"./src/Core/iServer/SetLayerInfoService.js",
3333
"./src/Core/iServer/SetLayersInfoService.js",
3434
"./src/Core/iServer/SetLayerStatusService.js",
35+
//ThemeService
36+
"./src/Core/iServer/ThemeService.js",
3537
//NetworkAnalyst
3638
"./src/Core/iServer/BurstPipelineAnalystService.js",
3739
"./src/Core/iServer/ComputeWeightMatrixService.js",
@@ -104,6 +106,12 @@ var deps = {
104106
"./src/Leaflet/SuperMap/iServer/GetGridCellInfosService.js"
105107
]
106108
},
109+
"Theme": {
110+
"name": "服务器专题图服务",
111+
"src": [
112+
"./src/Leaflet/SuperMap/iServer/ThemeService.js"
113+
]
114+
},
107115
"NetworkAnalyst": {
108116
"name": "网络分析服务",
109117
"src": [
@@ -128,7 +136,6 @@ var deps = {
128136
"./src/Leaflet/SuperMap/iServer/TrafficTransferAnalystService.js"
129137
]
130138
}
131-
132139
},
133140
"Visual": {
134141
"title": "Visual",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>等级符号专题图</title>
6+
<link rel="stylesheet" href="../css/bootstrap.min.css">
7+
<link rel="stylesheet" href="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css">
8+
<script type="text/javascript" src="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.js"></script>
9+
<script type="text/javascript" src="../../dist/SuperMapiClient9 for Leaflet.js"></script>
10+
<script type="text/javascript">
11+
var map, themeService, themeLayer,
12+
url = "http://support.supermap.com.cn:8090/iserver/services/map-china400/rest/maps/China";
13+
function init() {
14+
map = L.map('map', {
15+
center: [39, 116],
16+
maxZoom: 18,
17+
zoom: 4
18+
});
19+
L.supermap.tiledMapLayer(url).addTo(map);
20+
themeService = L.supermap.themeService(url);
21+
22+
}
23+
function createTheme() {
24+
var graStyle = new ThemeGraduatedSymbolStyle({
25+
positiveStyle: new ServerStyle({
26+
markerSize: 50,
27+
markerSymbolID: 0,
28+
lineColor: new ServerColor(255, 165, 0),
29+
fillBackColor: new ServerColor(255, 0, 0)
30+
})
31+
});
32+
var themeGraduatedSymbol = new ThemeGraduatedSymbol({
33+
expression: "SMAREA",
34+
baseValue: 3000000000000,
35+
graduatedMode: GraduatedMode.CONSTANT,
36+
flow: new ThemeFlow({
37+
flowEnabled: true
38+
}),
39+
style: graStyle
40+
});
41+
var themeParameters = new ThemeParameters({
42+
themes: [themeGraduatedSymbol],
43+
datasetNames: ["China_Province_pg"],
44+
dataSourceNames: ["China"]
45+
});
46+
themeService.getThemeStatus(themeParameters).on('complete', function (serviceResult) {
47+
console.log(serviceResult.result);
48+
var result = serviceResult.result;
49+
if (result && result.newResourceID) {
50+
themeLayer = L.supermap.tiledMapLayer(url, {
51+
cacheEnabled: false,
52+
transparent: true,
53+
layersID: result.newResourceID
54+
}).addTo(map);
55+
}
56+
}).on('failed', function (error) {
57+
alert(error.errorMsg);
58+
});
59+
}
60+
61+
function clearLayer() {
62+
if (themeLayer) {
63+
map.removeLayer(themeLayer);
64+
}
65+
}
66+
67+
</script>
68+
</head>
69+
<body onload="init()" style=" margin: 0;overflow: hidden;background: #fff;">
70+
<div id="toolbar" style=" position: relative;padding-top: 10px; padding-bottom: 10px;">
71+
<input type="button" class="btn btn-primary" value="创建专题图" onclick="createTheme()"/>
72+
<input type="button" class="btn btn-primary" value="清除结果" onclick="clearLayer()"/>
73+
</div>
74+
<div id="map" style="margin:0 auto;position: relative; height: 510px;border: 1px solid #3473b7;"></div>
75+
</body>
76+
</html>
File renamed without changes.

examples/leaflet/examples.html

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ <h3>Leaflet范例分类</h3>
3939
<ul class="nav nav-tabs" id='myTab'>
4040
<li class='active'><a href="#maps" data-toggle="tab">地图</a></li>
4141
<li><a href="#data" data-toggle="tab">数据</a></li>
42+
<li><a href="#theme" data-toggle="tab">专题图</a></li>
4243
<li><a href="#spatialAnalyst" data-toggle="tab">空间分析</a></li>
4344
<li><a href="#networkAnalyst" data-toggle="tab">网络分析</a></li>
4445
<li><a href="#trafficTransferAnalyst" data-toggle="tab">交通换乘分析</a></li>
@@ -144,6 +145,24 @@ <h3>Leaflet范例分类</h3>
144145
</div>
145146
</div>
146147

148+
<div class='tab-pane fade' id='theme'>
149+
150+
<div class="container-fluid">
151+
<div class="row-fluid">
152+
<div class="span2">
153+
<ul class='nav nav-pills'><span>></span>
154+
<li>服务器专题图</li>
155+
</ul>
156+
</div>
157+
<div class="span10">
158+
<ul class='nav nav-pills'>
159+
<li><a href='javascript:void(0)' target='_self' data-name='03_themeGraduatedSymbol'>等级符号专题图</a></li>
160+
</ul>
161+
</div>
162+
</div>
163+
</div>
164+
</div>
165+
147166
<div class='tab-pane fade' id='spatialAnalyst'>
148167

149168
<div class="container-fluid">
@@ -155,7 +174,7 @@ <h3>Leaflet范例分类</h3>
155174
</div>
156175
<div class="span10">
157176
<ul class='nav nav-pills'>
158-
<li><a href='javascript:void(0)' target='_self' data-name='03_bufferAnalystService'>缓冲区分析</a></li>
177+
<li><a href='javascript:void(0)' target='_self' data-name='04_bufferAnalystService'>缓冲区分析</a></li>
159178
</ul>
160179
</div>
161180
</div>
@@ -173,7 +192,7 @@ <h3>Leaflet范例分类</h3>
173192
</div>
174193
<div class="span10">
175194
<ul class='nav nav-pills'>
176-
<li><a href='javascript:void(0)' target='_self' data-name='04_findServiceAreas'>服务区分析</a></li>
195+
<li><a href='javascript:void(0)' target='_self' data-name='05_findServiceAreas'>服务区分析</a></li>
177196
</ul>
178197
</div>
179198
</div>

src/Core/iServer/LabelImageCell.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
/**
6+
* Class: LabelImageCell
7+
* 图片类型的矩阵标签元素类。
8+
* 该类继承自 LabelMatrixCell类,主要对矩阵标签中的专题图类型的矩阵标签元素进行设置。
9+
* 矩阵标签专题图是标签专题图(ThemeLabel)的一种,其中矩阵标签中的填充元素又可分为图片类型(LabelImageCell)、
10+
* 符号类型(LabelSymbolCell)、专题图类型(LabelThemeCell)三种,该类是这三种类型的矩阵标签元素其中的一种,
11+
* 用于定义符号类型的矩阵标签,如符号 ID 字段名称(符号 ID 与 SuperMap 桌面产品中点、线、面符号的 ID 对应) 、大小等。
12+
* 用户在实现矩阵标签专题图时只需将定义好的矩阵标签元素赋值予 ThemeLabel.matrixCells 属性即可。matrixCells 属是一个二维数组,
13+
* 每一维可以是任意类型的矩阵标签元素组成的数组(也可是单个标签元素组成的数组,即数组中只有一个元素)。
14+
*
15+
* Inherits from:
16+
* - <LabelMatrixCell>
17+
*/
18+
require('../base');
19+
require('./LabelMatrixCell');
20+
LabelImageCell = SuperMap.Class(LabelMatrixCell, {
21+
22+
/**
23+
* APIProperty: height
24+
* {Number} 设置图片的高度,单位为毫米。
25+
*/
26+
height: 0,
27+
28+
/**
29+
* APIProperty: pathField
30+
* {String} 设置矩阵标签元素所使用的图片路径对应的字段名。
31+
*/
32+
pathField: null,
33+
34+
/**
35+
* APIProperty: rotation
36+
* {Number} 图片的旋转角度。逆时针方向为正方向,单位为度,精确到0.1度。默认值为0.0。
37+
*/
38+
rotation: 0.0,
39+
40+
/**
41+
* APIProperty: width
42+
* {Number} 设置图片的宽度,单位为毫米。
43+
*/
44+
width: 0,
45+
46+
/**
47+
* APIProperty: sizeFixed
48+
* {Boolean} 是否固定图片的大小。默认值为 false,即图片将随地图缩放。
49+
*/
50+
sizeFixed: false,
51+
52+
/**
53+
* Property: type
54+
* {Boolean} 制作矩阵专题图时是必须的。
55+
*/
56+
type: "IMAGE",
57+
58+
/**
59+
* Constructor: LabelImageCell
60+
* 图片类型的矩阵标签元素类构造函数,用于创建 LabelImageCell 类的新实例。
61+
*
62+
* Parameters:
63+
* options - {Object} 参数。
64+
*
65+
* Allowed options properties:
66+
* height - {Number} 设置图片的高度,单位为毫米。
67+
* pathField - {String} 设置矩阵标签元素所使用图片的路径。
68+
* rotation - {Number} 图片的旋转角度。逆时针方向为正方向,单位为度,精确到0.1度。默认值为0.0。
69+
* width - {Number} 设置图片的宽度,单位为毫米。
70+
* sizeFixed - {Boolean} 是否固定图片的大小。默认值为 false,即图片将随地图缩放。
71+
*/
72+
initialize: function (options) {
73+
if (options) {
74+
SuperMap.Util.extend(this, options);
75+
}
76+
},
77+
78+
/**
79+
* APIMethod: destroy
80+
* 释放资源,将引用资源的属性置空。
81+
*/
82+
destroy: function () {
83+
var me = this;
84+
me.height = null;
85+
me.pathField = null;
86+
me.rotation = null;
87+
me.width = null;
88+
me.sizeFixed = null;
89+
},
90+
91+
CLASS_NAME: "LabelImageCell"
92+
});
93+
module.exports = function (options) {
94+
return new LabelImageCell(options);
95+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
/**
6+
* Class: LabelMatrixCell
7+
* 矩阵标签元素抽象类。
8+
* 该类可以包含 n*n 个矩阵标签元素,矩阵标签元素的类型可以是图片,符号,标签专题图等。
9+
* 符号类型的矩阵标签元素类、图片类型的矩阵标签元素类和专题图类型的矩阵标签元素类均继承自该类。
10+
*/
11+
require('../base');
12+
LabelMatrixCell = SuperMap.Class({
13+
CLASS_NAME: "LabelMatrixCell"
14+
});
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
/**
6+
* Class: LabelMixedTextStyle
7+
* 标签文本复合风格类。
8+
* 该类主要用于对标签专题图中标签的文本内容进行风格设置。通过该类用户可以使标签的文字显示不同的风格,
9+
* 比如文本 “喜马拉雅山”,通过本类可以将前三个字用红色显示,后两个字用蓝色显示。
10+
* 对同一文本设置不同的风格实质上是对文本的字符进行分段,同一分段内的字符具有相同的显示风格。
11+
* 对字符分段有两种方式,一种是利用分隔符对文本进行分段;另一种是根据分段索引值进行分段。
12+
* 1. 利用分隔符对文本进行分段: 比如文本 “5&109” 被分隔符 “&” 分为“5”和“109”两部分,
13+
* 在显示时,“5” 和分隔符 “&” 使用同一个风格,字符串 “109” 使用相同的风格。
14+
* 2. 利用分段索引值进行分段: 文本中字符的索引值是以0开始的整数,比如文本“珠穆朗玛峰”,
15+
* 第一个字符(“珠”)的索引值为0,第二个字符(“穆”)的索引值为1,以此类推;当设置分段索引值为1,3,4,9时,
16+
* 字符分段范围相应的就是(-∞,1),[1,3),[3,4),[4,9),[9,+∞),可以看出索引号为0的字符(即“珠” )在第一个分段内,
17+
* 索引号为1,2的字符(即“穆”、“朗”)位于第二个分段内,索引号为3的字符(“玛”)在第三个分段内,索引号为4的字符(“峰”)在第四个分段内,其余分段中没有字符。
18+
*/
19+
require('../base');
20+
require('./ServerTextStyle');
21+
LabelMixedTextStyle = SuperMap.Class({
22+
23+
/**
24+
* APIProperty: defaultStyle
25+
* {<ServerTextStyle>} 默认的文本复合风格,即 ServerTextStyle 各字段的默认值。
26+
*/
27+
defaultStyle: null,
28+
29+
/**
30+
* APIProperty: separator
31+
* {String} 文本的分隔符,分隔符的风格与前一个字符的风格一样。文本的分隔符是一个将文本分割开的符号,
32+
* 比如文本 “5_109” 被 “_” 隔符为 “5” 和 “109” 两部分,假设有风格数组:style1、style2。
33+
* 在显示时,“5” 和分隔符 “_” 使用 Style1 风格渲染,字符串 “109” 使用 Style2 的风格。
34+
*/
35+
separator: null,
36+
37+
/**
38+
* APIProperty: separatorEnabled
39+
* {Boolean} 文本的分隔符是否有效。分隔符有效时利用分隔符对文本进行分段;无效时根据文本中字符的位置进行分段。
40+
* 分段后,同一分段内的字符具有相同的显示风格。默认为 false。
41+
*/
42+
separatorEnabled: false,
43+
44+
/**
45+
* APIProperty: splitIndexes
46+
* {Array(Number)} 分段索引值,分段索引值用来对文本中的字符进行分段。
47+
* 文本中字符的索引值是以0开始的整数,比如文本“珠穆朗玛峰”,第一个字符(“珠”)的索引值为0,第二个字符(“穆”)的索引值为1,
48+
* 以此类推;当设置分段索引值数组为[1,3,4,9]时,字符分段范围相应的就是(-∞,1),[1,3),[3,4),[4,9),[9,+∞),
49+
* 可以看出索引号为0的字符(即“珠” )在第一个分段内,索引号为1,2的字符(即“穆”、“朗”)位于第二个分段内,
50+
* 索引号为3的字符(“玛”)在第三个分段内,索引号为4的字符(“峰”)在第四个分段内,其余分段中没有字符。
51+
*/
52+
splitIndexes: null,
53+
54+
/**
55+
* APIProperty: styles
56+
* {Array(<ServerTextStyle>)} 文本样式集合。文本样式集合中的样式根据索引与不同分段一一对应,
57+
* 如果有分段没有风格对应则使用 defaultStyle。
58+
*/
59+
styles: null,
60+
/**
61+
* Constructor: LabelMixedTextStyle
62+
* 标签文本复合风格类构造函数,用于创建 LabelMixedTextStyle 类的新实例。
63+
*
64+
* Parameters:
65+
* options - {Object} 参数。
66+
*
67+
* Allowed options properties:
68+
* defaultStyle - {<ServerTextStyle>} 默认的文本复合风格。
69+
* separator - {String} 文本的分隔符。
70+
* separatorEnabled - Boolean} 文本的分隔符是否有效。
71+
* splitIndexes - {Array(Number)} 分段索引值,分段索引值用来对文本中的字符进行分段。
72+
* styles - {Array(<ServerTextStyle>)} 文本样式集合。
73+
*/
74+
initialize: function (options) {
75+
var me = this;
76+
me.defaultStyle = new ServerTextStyle();
77+
if (options) {
78+
SuperMap.Util.extend(this, options);
79+
}
80+
},
81+
82+
/**
83+
* APIMethod: destroy
84+
* 释放资源,将引用资源的属性置空。
85+
*/
86+
destroy: function () {
87+
var me = this;
88+
if (me.defaultStyle) {
89+
me.defaultStyle.destroy();
90+
me.defaultStyle = null;
91+
}
92+
me.separator = null;
93+
me.separatorEnabled = null;
94+
if (me.splitIndexes) {
95+
me.splitIndexes = null;
96+
}
97+
if (me.styles) {
98+
for (var i = 0, styles = me.styles, len = styles.length; i < len; i++) {
99+
styles[i].destroy();
100+
}
101+
me.styles = null;
102+
}
103+
},
104+
105+
CLASS_NAME: "LabelMixedTextStyle"
106+
});
107+
LabelMixedTextStyle.fromObj = function (obj) {
108+
if (!obj) return;
109+
var res = new LabelMixedTextStyle();
110+
var stys = obj.styles;
111+
SuperMap.Util.copy(res, obj);
112+
res.defaultStyle = new ServerTextStyle(obj.defaultStyle);
113+
if (stys) {
114+
res.styles = [];
115+
for (var i = 0, len = stys.length; i < len; i++) {
116+
res.styles.push(new ServerTextStyle(stys[i]));
117+
}
118+
}
119+
return res;
120+
};
121+
module.exports = function (options) {
122+
return new LabelMixedTextStyle(options);
123+
};
124+

0 commit comments

Comments
 (0)