Skip to content

Commit 6bc74fa

Browse files
committed
fix classic 示例部分缺陷。review by caoxinke.
1 parent f74aa8c commit 6bc74fa

File tree

3 files changed

+53
-32
lines changed

3 files changed

+53
-32
lines changed

examples/classic/controler_featureSnap.html

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h5 class='panel-title text-center'>要素编辑</h5>
2222
<div class='panel-body' id='params'>
2323
<p></p>
2424
<div align='right' class='button-group'>
25-
<input type='button' id='btn1' class='btn btn-primary' value='关闭捕捉' onclick="switch_snap()"/>
25+
<input type='button' id='switchSnap' class='btn btn-primary' value='关闭捕捉' onclick="switch_snap()"/>
2626
<input type='button' id='btn2' class='btn btn-primary' value='加载数据' onclick="addData()"/>
2727
<input type='button' id='btn3' class='btn btn-primary' value='清除' onclick="clearFeatures()"/>
2828
</div>
@@ -37,42 +37,43 @@ <h5 class='panel-title text-center'>要素编辑</h5>
3737
switchSnap,
3838
snap01,
3939
url = host + "/iserver/services/map-world/rest/maps/World";
40-
//新建矢量图层
41-
vector = new SuperMap.Layer.Vector("vectorLayer");
42-
//创建捕捉对象,第一个参数指的是需要进行捕捉的要素图层,后面两个参数分别是点要素和线要素的捕捉容限,第四个参数是附加参数
40+
//新建矢量图层
41+
vector = new SuperMap.Layer.Vector("vectorLayer");
42+
//创建捕捉对象,第一个参数指的是需要进行捕捉的要素图层,后面两个参数分别是点要素和线要素的捕捉容限,第四个参数是附加参数
4343

44-
snap01 = new SuperMap.Snap([vector], 10, 10, {actived: true});
45-
//矢量要素编辑控件
46-
modifyFeature = new SuperMap.Control.ModifyFeature(vector);
47-
modifyFeature.snap = snap01;
44+
snap01 = new SuperMap.Snap([vector], 10, 10, {actived: true});
45+
//矢量要素编辑控件
46+
modifyFeature = new SuperMap.Control.ModifyFeature(vector);
47+
modifyFeature.snap = snap01;
4848

49-
//定义layer图层,TiledDynamicRESTLayer:分块动态 REST 图层
50-
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {
51-
transparent: true,
52-
cacheEnabled: true
53-
}, {maxResolution: "auto"});
54-
switchSnap = document.getElementById("switchSnap");
55-
//为图层初始化完毕添加addLayer()事件
56-
layer.events.on({"layerInitialized": addLayer});
57-
map = new SuperMap.Map("map", {
58-
controls: [
59-
new SuperMap.Control.LayerSwitcher(),
60-
new SuperMap.Control.ScaleLine(),
61-
new SuperMap.Control.Zoom(),
62-
new SuperMap.Control.Navigation({
63-
dragPanOptions: {
64-
enableKinetic: true
65-
}
66-
}),
67-
modifyFeature]
68-
});
69-
addData();
49+
//定义layer图层,TiledDynamicRESTLayer:分块动态 REST 图层
50+
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {
51+
transparent: true,
52+
cacheEnabled: true
53+
}, {maxResolution: "auto"});
54+
switchSnap = document.getElementById("switchSnap");
55+
//为图层初始化完毕添加addLayer()事件
56+
layer.events.on({"layerInitialized": addLayer});
57+
map = new SuperMap.Map("map", {
58+
controls: [
59+
new SuperMap.Control.LayerSwitcher(),
60+
new SuperMap.Control.ScaleLine(),
61+
new SuperMap.Control.Zoom(),
62+
new SuperMap.Control.Navigation({
63+
dragPanOptions: {
64+
enableKinetic: true
65+
}
66+
}),
67+
modifyFeature]
68+
});
69+
addData();
7070

7171
function addLayer() {
7272
map.addLayers([layer, vector]);
7373
map.setCenter(new SuperMap.LonLat(0, 0), 1);
7474

7575
}
76+
7677
function edit_feature() {
7778
deactiveAll();
7879
modifyFeature.activate();
@@ -84,14 +85,17 @@ <h5 class='panel-title text-center'>要素编辑</h5>
8485
snapState = false;
8586
snap01.off();
8687
}
88+
8789
function activate_snap_all() {
8890
snapState = true;
8991
snap01.on();
9092
}
93+
9194
function switch_snap() {
9295
snapState ? switchSnap.value = "开启捕捉" : switchSnap.value = "关闭捕捉";
9396
snapState ? deactivate_snap_all() : activate_snap_all();
9497
}
98+
9599
function deactiveAll() {
96100
modifyFeature.deactivate();
97101
deactivate_snap_all();
@@ -140,7 +144,7 @@ <h5 class='panel-title text-center'>要素编辑</h5>
140144

141145
dataAdded = true;
142146
} else {
143-
widgets.alert.showAlert("数据已加载。",true,220);
147+
widgets.alert.showAlert("数据已加载。", true, 220);
144148
}
145149
edit_feature();
146150
}

examples/classic/popup_customPopup.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>自定义信息框</title>
6-
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
6+
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
77
<script type="text/javascript" exclude="iclient-classic" src="../../dist/include-classic.js"></script>
88
<style type="text/css">
99
body {
@@ -56,7 +56,7 @@ <h5 class='panel-title text-center'>自定义信息框</h5></div>
5656
<div id="map"></div>
5757
<script>
5858
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
59-
var map, layerWorld, marker, markers;
59+
var map, layerWorld, marker, markers, popup;
6060
var url = host + "/iserver/services/map-world/rest/maps/World";
6161

6262
init();
@@ -90,6 +90,7 @@ <h5 class='panel-title text-center'>自定义信息框</h5></div>
9090

9191
//定义mouseClickHandler函数,触发click事件会调用此函数
9292
function mouseClickHandler(event) {
93+
widgets.alert.clearAlert();
9394
closeInfoWin();
9495
//初始化popup类
9596
popup = new SuperMap.Popup(
@@ -147,6 +148,11 @@ <h5 class='panel-title text-center'>自定义信息框</h5></div>
147148

148149
//设置弹出框的背景颜色.
149150
function changecolor() {
151+
widgets.alert.clearAlert();
152+
if (!popup) {
153+
widgets.alert.showAlert("请先点击事件点,创建popup。", false, 220);
154+
return;
155+
}
150156
var colorStr = document.getElementById('popupColor').value;
151157
if (colorStr) {
152158
popup.setBackgroundColor(colorStr);
@@ -155,6 +161,11 @@ <h5 class='panel-title text-center'>自定义信息框</h5></div>
155161

156162
//设置弹出框的透明度.
157163
function changeopacity() {
164+
widgets.alert.clearAlert();
165+
if (!popup) {
166+
widgets.alert.showAlert("请先点击事件点,创建popup。", false, 220);
167+
return;
168+
}
158169
var opacityStr = document.getElementById('popupOpacity').value;
159170
popup.setOpacity(opacityStr);
160171
}

examples/classic/theme_themeUnique.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ <h5 class='panel-title text-center'>等级符号专题图</h5>
256256
widgets.alert.showAlert(serviceFailedEventArgs.error.errorMsg,false);
257257
}
258258

259+
function removeTheme() {
260+
if (map.layers.length > 1) {
261+
map.removeLayer(themeLayer, true);
262+
}
263+
}
264+
259265
</script>
260266
</body>
261267
</html>

0 commit comments

Comments
 (0)