Skip to content

Commit ac49952

Browse files
author
潘卓然ParnDeedlit
committed
【站点】【修复】【修复MapboxGL客户端专题图示例】
1 parent 1341855 commit ac49952

File tree

4 files changed

+106
-65
lines changed

4 files changed

+106
-65
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ src/config/opensource/output/
3030
/website/public/static/data/echarts/line/
3131
/website/public/static/data/echarts/point/
3232
/website/public/static/data/echarts/road/
33+
/website/public/static/libs
3334
/website/public/static/libs/cdn
3435

35-
package-lock.json
36+
package-lock.json
37+
yarn.lock

website/public/static/demo/config/config-mapboxgl.json

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,62 @@
724724
"update": "最后更新时间:2018-07-06"
725725
}
726726
]
727-
}
727+
}, {
728+
"name": "客户端专题图",
729+
"iconfont": "icontheme",
730+
"folder": "clienttheme",
731+
"leaffolder": true,
732+
"childs": [
733+
{
734+
"name": "单值",
735+
"file": "unique",
736+
"diffcult": "1",
737+
"detail": "",
738+
"icon": "unique.png",
739+
"update": "最后更新时间:"
740+
},
741+
{
742+
"name": "分段",
743+
"file": "range",
744+
"diffcult": "1",
745+
"detail": "",
746+
"icon": "range.png",
747+
"update": "最后更新时间:"
748+
},
749+
{
750+
"name": "随机",
751+
"file": "random",
752+
"diffcult": "1",
753+
"detail": "",
754+
"icon": "random.png",
755+
"update": "最后更新时间:"
756+
},
757+
{
758+
"name": "统一",
759+
"file": "simple",
760+
"diffcult": "1",
761+
"detail": "",
762+
"icon": "simple.png",
763+
"update": "最后更新时间:"
764+
},
765+
{
766+
"name": "等级符号",
767+
"file": "grade-symbol",
768+
"diffcult": "1",
769+
"detail": "",
770+
"icon": "grade-symbol.png",
771+
"update": "最后更新时间:"
772+
},
773+
{
774+
"name": "统计",
775+
"file": "graphic",
776+
"diffcult": "1",
777+
"detail": "",
778+
"icon": "graphic.png",
779+
"update": "最后更新时间:"
780+
}
781+
]
782+
}
728783
]
729784
},
730785
{

website/public/static/demo/mapboxgl/example/client-view/clienttheme/grade-symbol.htm

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
 <!DOCTYPE html>
2-
<html xmlns="http://www.w3.org/1999/xhtml">
3-
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
43
<head>
54
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
65
<title>客户端等级符号专题图</title>
7-
<!--引入当前页面样式表-->
8-
<link href="./style.css" rel="stylesheet" type="text/css" />
6+
<!--引入当前页面样式表-->
7+
<link href="./style.css" rel="stylesheet" type="text/css" />
98
<script src="./static/libs/include-mapboxgl-local.js"></script>
109
<style>
1110
body {
@@ -14,7 +13,7 @@
1413
</style>
1514
<script type="text/javascript">
1615
//使用严格模式
17-
"use strict";
16+
'use strict';
1817
//定义地图文档图层和地图、专题图图层
1918
var mapDocLayer, map, themeLayer;
2019
var { protocol, ip, port } = window.webclient;
@@ -25,30 +24,30 @@
2524
/** 初始化地图显示*/
2625
function init() {
2726
//地图容器
28-
map = L.map('leaf_map', {
29-
//地图渲染在canvas上
30-
preferCanvas: true,
31-
//不添加属性说明控件
32-
attributionControl: false,
33-
//添加缩放控件
34-
zoomControl: true,
35-
//投影坐标系
36-
crs: L.CRS.EPSG4326,
37-
//最大级数
38-
maxZoom: 15,
39-
//最小级数
40-
minZoom: 0
41-
}).setView([(29.0125822276524 + 33.2932017737021) / 2, (108.34341 + 116.150939561213)
42-
/ 2], 6);
43-
//创建地图文档图层
44-
mapDocLayer = new Zondy.Map.MapDocLayer(docName, {
45-
//IP地址
46-
ip: ip,
47-
//端口号
48-
port: port,
49-
//只显示一个图层,不平铺显示
50-
noWrap: true
51-
}).addTo(map);
27+
//地图容器
28+
map = new window.mapboxgl.Map({
29+
container: 'map',
30+
minZoom: 3,
31+
center: [112.247175, 31.152892],
32+
style: { version: 8, sources: {}, layers: [] }
33+
});
34+
35+
function appendMapDoc() {
36+
if (map != null) {
37+
var docLayer = new mapboxgl.Zondy.Map.MapDocLayer(docName, {
38+
//IP地址
39+
ip: ip,
40+
//端口号
41+
port: port,
42+
//只显示一个图层,不平铺显示
43+
noWrap: true
44+
});
45+
docLayer.addToMap(map);
46+
}
47+
}
48+
map.on('load', function () {
49+
appendMapDoc();
50+
});
5251
}
5352

5453
/** 添加专题图*/
@@ -68,7 +67,7 @@
6867
queryStruct.IncludeWebGraphic = false;
6968
//实例化查询参数对象
7069
var queryParam = new Zondy.Service.QueryParameter({
71-
resultFormat: "json",
70+
resultFormat: 'json',
7271
struct: queryStruct
7372
});
7473
//设置查询分页号
@@ -89,9 +88,8 @@
8988
/** 生成专题图*/
9089
function gradeQuerySuccess(data) {
9190
if (data != null) {
92-
themeLayer =
93-
Zondy.Map.rankSymbolThemeLayer("ThemeLayer", 'Circle', { calGravity: true });
94-
themeLayer.themeField = "GDP2016";
91+
themeLayer = Zondy.Map.rankSymbolThemeLayer('ThemeLayer', 'Circle', { calGravity: true });
92+
themeLayer.themeField = 'GDP2016';
9593
// 配置图表参数
9694
themeLayer.symbolSetting = {
9795
//允许图形展示的值域范围,此范围外的数据将不制作图图形,必设参数
@@ -103,7 +101,7 @@
103101
// 圆形样式
104102
circleStyle: { fillOpacity: 0.8 },
105103
// 符号专题图填充颜色
106-
fillColor: "#00FF7F",
104+
fillColor: '#00FF7F',
107105
// 专题图hover 样式
108106
circleHoverStyle: {
109107
fillOpacity: 1,
@@ -114,7 +112,7 @@
114112
};
115113
map.addLayer(themeLayer);
116114
themeLayer.on('mousemove', showInfoWin);
117-
themeLayer.on("mouseout", closeInfoWin);
115+
themeLayer.on('mouseout', closeInfoWin);
118116
themeLayer.addFeatures(data);
119117
}
120118
stopPressBar();
@@ -142,17 +140,14 @@
142140
var info = e.target.dataInfo;
143141
// 弹窗内容
144142
var contentHTML = "<div style='color: #000; background-color: #fff'>";
145-
contentHTML += "行政区:" + "<br><strong>" + fea.attributes['NAME'] + "</strong>";
143+
contentHTML += '行政区:' + '<br><strong>' + fea.attributes['NAME'] + '</strong>';
146144

147145
contentHTML += "<hr style='margin: 3px'>";
148-
contentHTML += "GDP2016: <br/><strong>" + info.value + "</strong>(亿元)";
149-
contentHTML += "</div>";
146+
contentHTML += 'GDP2016: <br/><strong>' + info.value + '</strong>(亿元)';
147+
contentHTML += '</div>';
150148

151149
var tempPoint = map.mouseEventToLatLng(e.event);
152-
popup = L.tooltip({ direction: 'top' })
153-
.setContent(contentHTML)
154-
.setLatLng([tempPoint.lat, tempPoint.lng])
155-
.addTo(map);
150+
popup = L.tooltip({ direction: 'top' }).setContent(contentHTML).setLatLng([tempPoint.lat, tempPoint.lng]).addTo(map);
156151
return;
157152
}
158153
}
@@ -166,28 +161,26 @@
166161

167162
/** 开始进度条动画*/
168163
function startPressBar() {
169-
document.getElementById('preview').style.display = "";
164+
document.getElementById('preview').style.display = '';
170165
}
171166

172167
/** 停止进度条动画*/
173168
function stopPressBar() {
174-
document.getElementById('preview').style.display = "none";
169+
document.getElementById('preview').style.display = 'none';
175170
}
176171
</script>
177172
</head>
178173

179174
<body onload="init();">
180175
<div id="preview" style="display: none; text-align: center; padding-top: 250px; font-weight: bold">
181-
<img src="./static/assets/graphic-image/39-1.gif" alt='' /><br />
176+
<img src="./static/assets/graphic-image/39-1.gif" alt="" /><br />
182177
<br />
183178
<span>正在操作,请稍候</span>
184179
</div>
185180
<div class="ToolLib">
186181
<input type="button" class="ButtonLib" id="createThemeBtn" value="添加专题图" onclick="createThemeBtn()" />
187182
<input type="button" class="ButtonLib" id="deleteThemeBtn" value="删除专题图" onclick="deleteTheme()" />
188183
</div>
189-
<div id="leaf_map" style="width: 100%; height:95%;">
190-
</div>
184+
<div id="map" style="width: 100%; height: 95%; position: absolute; top: 34px; background-color: #d8d4d4"></div>
191185
</body>
192-
193-
</html>
186+
</html>

website/public/static/demo/mapboxgl/example/client-view/clienttheme/range.htm

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
}
9191
}
9292
map.on('load', function () {
93-
appendMapDoc();
93+
// appendMapDoc();
9494
});
9595
}
9696

@@ -99,6 +99,7 @@
9999
function createThemeBtn() {
100100
startPressBar();
101101
themeLayer = Zondy.Map.rangeThemeLayer('ThemeLayer', {
102+
map: map,
102103
// 开启 hover 高亮效果
103104
isHoverAble: true,
104105
opacity: 0.8,
@@ -161,9 +162,8 @@
161162
}
162163
}
163164
];
164-
map.addLayer(themeLayer);
165165
themeLayer.on('mousemove', highLightLayer);
166-
addThemeFeatures(querySuccess);
166+
addThemeFeatures(rangeQuerySuccess);
167167
}
168168

169169
function addThemeFeatures(onsuccess) {
@@ -196,22 +196,13 @@
196196
queryService.query(onsuccess, null);
197197
}
198198

199-
function querySuccess(data) {
200-
if (data != null) {
201-
//客户端专题图:添加数据
202-
themeLayer.addFeatures(data);
203-
document.getElementById('legendview').style.display = 'block';
204-
}
199+
function rangeQuerySuccess(data) {
205200
stopPressBar();
206-
}
207-
208-
function uniqueQuerySuccess(data) {
209201
if (data != null) {
210202
//客户端专题图:添加数据
211203
themeLayer.addFeatures(data);
212204
document.getElementById('legendview').style.display = 'block';
213205
}
214-
stopPressBar();
215206
}
216207

217208
function highLightLayer(e) {

0 commit comments

Comments
 (0)