-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy path03_themeUnique.html
More file actions
267 lines (252 loc) · 10.9 KB
/
03_themeUnique.html
File metadata and controls
267 lines (252 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_themeUnique"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
<span id="show"></span>
<script type="text/javascript">
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
"with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
" Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
var dataUrl = host + "/iserver/services/map-china/rest/maps/China";
var map = new mapboxgl.Map({
container: 'map',
style: {
"version": 8,
"sources": {
"raster-tiles": {
"attribution": attribution,
"type": "raster",
"tiles": [host + '/iserver/services/map-china/rest/maps/China/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}'],
"tileSize": 256,
},
},
"layers": [{
"id": "simple-tiles",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22
}]
},
center: [110, 37],
zoom: 3
});
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
map.addControl(new mapboxgl.supermap.LogoControl({ link: "https://iclient.supermap.io" }), 'bottom-right');
function createTheme() {
var style1, style2, style3, style4, style5, style6;
style1 = new mapboxgl.supermap.ServerStyle({
fillForeColor: new mapboxgl.supermap.ServerColor(248, 203, 249),
lineColor: new mapboxgl.supermap.ServerColor(255, 255, 255),
lineWidth: 0.1
});
style2 = new mapboxgl.supermap.ServerStyle({
fillForeColor: new mapboxgl.supermap.ServerColor(196, 255, 189),
lineColor: new mapboxgl.supermap.ServerColor(255, 255, 255),
lineWidth: 0.1
});
style3 = new mapboxgl.supermap.ServerStyle({
fillForeColor: new mapboxgl.supermap.ServerColor(255, 173, 173),
lineColor: new mapboxgl.supermap.ServerColor(255, 255, 255),
lineWidth: 0.1
});
style4 = new mapboxgl.supermap.ServerStyle({
fillForeColor: new mapboxgl.supermap.ServerColor(255, 239, 168),
lineColor: new mapboxgl.supermap.ServerColor(255, 255, 255),
lineWidth: 0.1
});
style5 = new mapboxgl.supermap.ServerStyle({
fillForeColor: new mapboxgl.supermap.ServerColor(173, 209, 255),
lineColor: new mapboxgl.supermap.ServerColor(255, 255, 255),
lineWidth: 0.1
});
style6 = new mapboxgl.supermap.ServerStyle({
fillForeColor: new mapboxgl.supermap.ServerColor(132, 164, 232),
lineColor: new mapboxgl.supermap.ServerColor(255, 255, 255),
lineWidth: 0.1
});
var themeUniqueIteme1 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "黑龙江省",
style: style1
}),
themeUniqueIteme2 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "湖北省",
style: style2
}),
themeUniqueIteme3 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "吉林省",
style: style3
}),
themeUniqueIteme4 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "内蒙古自治区",
style: style4
}),
themeUniqueIteme5 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "青海省",
style: style5
}),
themeUniqueIteme6 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "新疆维吾尔自治区",
style: style6
}),
themeUniqueIteme7 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "云南省",
style: style1
}),
themeUniqueIteme8 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "四川省",
style: style4
}),
themeUniqueIteme9 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "贵州省",
style: style3
}),
themeUniqueIteme10 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "甘肃省",
style: style3
}),
themeUniqueIteme11 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "宁夏回族自治区",
style: style5
}),
themeUniqueIteme12 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "重庆市",
style: style6
}),
themeUniqueIteme13 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "山东省",
style: style1
}),
themeUniqueIteme14 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "安徽省",
style: style2
}),
themeUniqueIteme15 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "江西省",
style: style3
}),
themeUniqueIteme16 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "浙江省",
style: style4
}),
themeUniqueIteme17 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "台湾省",
style: style2
}),
themeUniqueIteme18 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "江苏省",
style: style6
}),
themeUniqueIteme19 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "湖南省",
style: style5
}),
themeUniqueIteme20 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "河南省",
style: style4
}),
themeUniqueIteme21 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "河北省",
style: style3
}),
themeUniqueIteme22 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "福建省",
style: style5
}),
themeUniqueIteme23 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "广西壮族自治区",
style: style6
}),
themeUniqueIteme24 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "西藏自治区",
style: style2
}),
themeUniqueIteme25 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "广东省",
style: style4
}),
themeUniqueIteme26 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "山西省",
style: style2
}),
themeUniqueIteme27 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "陕西省",
style: style1
}),
themeUniqueIteme28 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "天津市",
style: style5
}),
themeUniqueIteme29 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "北京市",
style: style2
}),
themeUniqueIteme30 = new mapboxgl.supermap.ThemeUniqueItem({
unique: "辽宁省",
style: style1
});
var themeUniqueItemes = [
themeUniqueIteme1, themeUniqueIteme2, themeUniqueIteme3, themeUniqueIteme4, themeUniqueIteme5,
themeUniqueIteme6, themeUniqueIteme7, themeUniqueIteme8, themeUniqueIteme9, themeUniqueIteme10,
themeUniqueIteme11, themeUniqueIteme12, themeUniqueIteme13, themeUniqueIteme14, themeUniqueIteme15,
themeUniqueIteme16, themeUniqueIteme17, themeUniqueIteme18, themeUniqueIteme19, themeUniqueIteme20,
themeUniqueIteme21, themeUniqueIteme22, themeUniqueIteme23, themeUniqueIteme24, themeUniqueIteme25,
themeUniqueIteme26, themeUniqueIteme27, themeUniqueIteme28, themeUniqueIteme29, themeUniqueIteme30
];
var themeUnique = new mapboxgl.supermap.ThemeUnique({
uniqueExpression: "Name",
items: themeUniqueItemes,
defaultStyle: style1
});
var themeParameters = new mapboxgl.supermap.ThemeParameters({
datasetNames: ["Province_R"],
dataSourceNames: ["China"],
themes: [themeUnique]
});
// new mapboxgl.supermap.ThemeService(dataUrl).getThemeInfo(themeParameters, function (serviceResult) {
// var result = serviceResult.result;
// if (result && result.newResourceID) {
// map.addSource("theme", {
// "type": 'raster',
// "tiles": [host + '/iserver/services/map-china/rest/maps/China/zxyTileImage.png?z={z}&x={x}&y={y}&noWrap=true&transparent=true&cacheEnabled=false&layersID=' + result.newResourceID],
// "tileSize": 256,
// });
// map.addLayer({
// "id": "themeLayer",
// "type": "raster",
// "source": "theme",
// });
// }
// })
new mapboxgl.supermap.ThemeService(dataUrl).getThemeInfo(themeParameters).then(function (serviceResult) {
var result = serviceResult.result;
if (result && result.newResourceID) {
map.addSource("theme", {
"type": 'raster',
"tiles": [host + '/iserver/services/map-china/rest/maps/China/zxyTileImage.png?z={z}&x={x}&y={y}&noWrap=true&transparent=true&cacheEnabled=false&layersID=' + result.newResourceID],
"tileSize": 256,
});
map.addLayer({
"id": "themeLayer",
"type": "raster",
"source": "theme",
});
}
})
}
map.on('load', function () {
createTheme();
});
</script>
</body>
</html>