Skip to content

Commit e484146

Browse files
committed
leaflet在线编辑页交互界面阻止地图缩放事件
1 parent d681721 commit e484146

15 files changed

+2386
-2192
lines changed

dist/iclient9-leaflet.js

Lines changed: 2072 additions & 2077 deletions
Large diffs are not rendered by default.

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/leaflet/02_editFeatures.html

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@
88
<link rel="stylesheet" href="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css">
99
</head>
1010
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
11-
<div id="toolbar" style="height:44px; padding-top: 6px; text-align: right ">
12-
<input type="button" class="btn btn-default" value="添加地物" onclick="addMarker()"/>
13-
<input type="button" class="btn btn-default" value="提交添加" onclick="commit()"/>
14-
<input type="button" class="btn btn-default" value="清除结果" onclick="clearLayer()"/>
15-
</div>
1611
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
17-
1812
<script type="text/javascript" src="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.js"></script>
1913
<script type="text/javascript" src="../../dist/iclient9-leaflet.min.js"></script>
2014
<script type="text/javascript">
2115
var map, marker, featureGroup, id, resultLayer, featureService,
22-
baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World",
23-
url = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data";
16+
baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World",
17+
url = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data";
2418
map = L.map('map', {
2519
preferCanvas: true,
2620
crs: L.CRS.EPSG4326,
@@ -32,13 +26,14 @@
3226
featureGroup = L.featureGroup().addTo(map);
3327
featureService = L.supermap.featureService(url);
3428
initFeature();
29+
initEditView();
30+
3531

3632
function initFeature() {
3733
var polygon = L.polygon([[10, 100], [10, 124], [40, 124], [40, 100], [10, 100]]);
3834
var getFeatureParams = new SuperMap.GetFeaturesByGeometryParameters({
3935
datasetNames: ["World:Capitals"],
40-
geometry: polygon,
41-
spatialQueryMode: "INTERSECT"
36+
geometry: polygon
4237
});
4338

4439
featureService.getFeaturesByGeometry(getFeatureParams, function (serviceResult) {
@@ -68,8 +63,8 @@
6863
function commit() {
6964
var me = this;
7065
if (featureGroup.hasLayer(marker)) {
71-
marker= marker.toGeoJSON();
72-
marker.properties={POP:1,CAPITAL:'test'};
66+
marker = marker.toGeoJSON();
67+
marker.properties = {POP: 1, CAPITAL: 'test'};
7368
var addFeatureParams = new SuperMap.EditFeaturesParameters({
7469
dataSourceName: "World",
7570
dataSetName: "Capitals",
@@ -89,6 +84,39 @@
8984
}
9085
}
9186

87+
function initEditView() {
88+
var infoView = L.control({position: 'topright'});
89+
infoView.onAdd = function () {
90+
var me = this;
91+
me._div = L.DomUtil.create('div', 'panel panel-primary infoPane');
92+
me._div.innerHTML = "<div class='panel-heading'>" +
93+
"<h5 class='panel-title text-center'>编辑</h5></div><div class='panel-body content'>" +
94+
"<input type='button' class='btn btn-default' value='添加地物' onclick='addMarker()'/>&nbsp;" +
95+
"<input type='button' class='btn btn-default' value='提交添加' onclick='commit()'/>&nbsp;" +
96+
"<input type='button' class='btn btn-default' value='清除结果' onclick='clearLayer()'/></div>";
97+
98+
handleMapEvent(me._div, me._map);
99+
return me._div;
100+
};
101+
infoView.addTo(map);
102+
}
103+
104+
function handleMapEvent(div, map) {
105+
if (!div || !map) {
106+
return;
107+
}
108+
div.addEventListener('mouseover', function () {
109+
map.dragging.disable();
110+
map.scrollWheelZoom.disable();
111+
map.doubleClickZoom.disable();
112+
});
113+
div.addEventListener('mouseout', function () {
114+
map.dragging.enable();
115+
map.scrollWheelZoom.enable();
116+
map.doubleClickZoom.enable();
117+
});
118+
}
119+
92120
function clearLayer() {
93121
var me = this;
94122
if (!featureGroup.hasLayer(marker)) {

examples/leaflet/02_fieldStatistics.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
info.onAdd = function () {
4242
this._div = L.DomUtil.create('div', 'resultInfo');
4343
info.update();
44+
handleMapEvent(this._div, this._map);
4445
return this._div;
4546
};
4647

@@ -130,6 +131,22 @@
130131
});
131132
}
132133
}
134+
135+
function handleMapEvent(div, map) {
136+
if (!div || !map) {
137+
return;
138+
}
139+
div.addEventListener('mouseover', function () {
140+
map.dragging.disable();
141+
map.scrollWheelZoom.disable();
142+
map.doubleClickZoom.disable();
143+
});
144+
div.addEventListener('mouseout', function () {
145+
map.dragging.enable();
146+
map.scrollWheelZoom.enable();
147+
map.doubleClickZoom.enable();
148+
});
149+
}
133150
</script>
134151
</body>
135152
</html>

examples/leaflet/06_trafficTransferAnalystService.html

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
<script type="text/javascript" src="../../dist/iclient9-leaflet.min.js"></script>
3434
<script type="text/javascript">
3535
var map, startMarker, endMarker, tempRedLayer, tempMarker,
36-
routeFeatureGroup, paths = {transSolutions: null, solutions: null}, info,
37-
baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-changchun/rest/maps/长春市区图",
38-
serviceUrl = "http://support.supermap.com.cn:8090/iserver/services/traffictransferanalyst-sample/restjsr/traffictransferanalyst/Traffic-Changchun";
36+
routeFeatureGroup, paths = {transSolutions: null, solutions: null}, info,
37+
baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-changchun/rest/maps/长春市区图",
38+
serviceUrl = "http://support.supermap.com.cn:8090/iserver/services/traffictransferanalyst-sample/restjsr/traffictransferanalyst/Traffic-Changchun";
3939
map = L.map('map', {
4040
crs: L.supermap.NonEarthCRS({
4141
bounds: L.bounds([48.4, -7668.25], [8958.85, -55.58]),
@@ -48,19 +48,19 @@
4848
L.supermap.tiledMapLayer(baseUrl, {noWrap: true}).addTo(map);
4949

5050
startMarker = L.marker([-5527.73795456, 3111.42533851])
51-
.addTo(map).bindTooltip("起点", {
52-
offset: L.point([0, -10]),
53-
direction: "top",
54-
permanent: true
55-
}).openTooltip();
51+
.addTo(map).bindTooltip("起点", {
52+
offset: L.point([0, -10]),
53+
direction: "top",
54+
permanent: true
55+
}).openTooltip();
5656

5757
endMarker = L.marker([-4270.0725196, 6055.3431955])
58-
.addTo(map)
59-
.bindTooltip("终点", {
60-
offset: L.point([0, -10]),
61-
direction: "top",
62-
permanent: true
63-
}).openTooltip();
58+
.addTo(map)
59+
.bindTooltip("终点", {
60+
offset: L.point([0, -10]),
61+
direction: "top",
62+
permanent: true
63+
}).openTooltip();
6464
routeFeatureGroup = L.featureGroup().addTo(map);
6565
tempRedLayer = L.featureGroup().addTo(map);
6666
initResultInfoWin();
@@ -71,6 +71,7 @@
7171
info.onAdd = function () {
7272
this._div = L.DomUtil.create('div', 'panel panel-primary');
7373
info.update();
74+
handleMapEvent(this._div, this._map);
7475
return this._div;
7576
};
7677

@@ -126,21 +127,21 @@
126127
points: paths.points //起始点坐标
127128
});
128129
L.supermap.trafficTransferAnalystService(serviceUrl)
129-
.analysisTransferSolution(params, function (serviceResult) {
130-
if (serviceResult.error) {
131-
alert("错误提示:" + serviceResult.error.errorMsg);
132-
}
133-
transferSolutionsSucceed(serviceResult.result);
134-
});
130+
.analysisTransferSolution(params, function (serviceResult) {
131+
if (serviceResult.error) {
132+
alert("错误提示:" + serviceResult.error.errorMsg);
133+
}
134+
transferSolutionsSucceed(serviceResult.result);
135+
});
135136
}
136137

137138
function transferSolutionsSucceed(result) {
138139
clearLayer();
139140
info.addTo(map);
140141
//在地图上叠加符号信息
141142
var transGuide = result.defaultGuide,
142-
transSolutions = result.solutionItems,
143-
solutions = [];
143+
transSolutions = result.solutionItems,
144+
solutions = [];
144145

145146
for (var j = 0; j < transSolutions.length; j++) {
146147
var linesItems = transSolutions[j].linesItems, transSolution = [];
@@ -149,8 +150,8 @@
149150
for (var jjj = 0; jjj < lineItems.length; jjj++) {
150151
var lineItem = lineItems[jjj];
151152
items.push("{'lineID':" + lineItem.lineID +
152-
",'startStopIndex':" + lineItem.startStopIndex +
153-
",'endStopIndex':" + lineItem.endStopIndex + "}"
153+
",'startStopIndex':" + lineItem.startStopIndex +
154+
",'endStopIndex':" + lineItem.endStopIndex + "}"
154155
);
155156
}
156157
transSolution.push(items);
@@ -187,7 +188,7 @@
187188
$("<td>" + parseInt(item.distance) + "米</td>").appendTo(tr2);
188189
} else {
189190
var otherLines = transSolutions[indexX].linesItems[indexY],
190-
links = "";
191+
links = "";
191192
if (otherLines && otherLines.lineItems.length > 1) {
192193
links = "</br>还可乘坐:"
193194
for (var oti = 0, otLen = otherLines.lineItems.length; oti < otLen; oti++) {
@@ -286,15 +287,31 @@
286287
transferLines: transLines
287288
});
288289
L.supermap
289-
.trafficTransferAnalystService(serviceUrl)
290-
.analysisTransferPath(params, function (serviceResult) {
291-
$("#transferInfo-" + id).empty();
292-
var transGuide = serviceResult.result;
293-
transSolutions = paths["transSolutions"];
294-
map.setView([-3900, 4700], 2);
295-
fillTransferInfo(transGuide, transSolutions, id).appendTo($("#transferInfo-" + id));
296-
setPopup();
297-
});
290+
.trafficTransferAnalystService(serviceUrl)
291+
.analysisTransferPath(params, function (serviceResult) {
292+
$("#transferInfo-" + id).empty();
293+
var transGuide = serviceResult.result;
294+
transSolutions = paths["transSolutions"];
295+
map.setView([-3900, 4700], 2);
296+
fillTransferInfo(transGuide, transSolutions, id).appendTo($("#transferInfo-" + id));
297+
setPopup();
298+
});
299+
}
300+
301+
function handleMapEvent(div, map) {
302+
if (!div || !map) {
303+
return;
304+
}
305+
div.addEventListener('mouseover', function () {
306+
map.dragging.disable();
307+
map.scrollWheelZoom.disable();
308+
map.doubleClickZoom.disable();
309+
});
310+
div.addEventListener('mouseout', function () {
311+
map.dragging.enable();
312+
map.scrollWheelZoom.enable();
313+
map.doubleClickZoom.enable();
314+
});
298315
}
299316

300317
function clearLayer() {

examples/leaflet/SummaryMeshJobService.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ <h4 class="modal-title">提示</h4>
8686
"<div align='right'>" +
8787
"<input type='button' id='btn' class='btn btn-primary' value='创建'/>" +
8888
"</div></div></div>";
89+
handleMapEvent(popup, this._map);
8990
return popup;
9091
};
9192
info.addTo(map);
@@ -133,7 +134,21 @@ <h4 class="modal-title">提示</h4>
133134
});
134135
});
135136
});
136-
137+
function handleMapEvent(div, map) {
138+
if (!div || !map) {
139+
return;
140+
}
141+
div.addEventListener('mouseover', function () {
142+
map.dragging.disable();
143+
map.scrollWheelZoom.disable();
144+
map.doubleClickZoom.disable();
145+
});
146+
div.addEventListener('mouseout', function () {
147+
map.dragging.enable();
148+
map.scrollWheelZoom.enable();
149+
map.doubleClickZoom.enable();
150+
});
151+
}
137152
</script>
138153
</body>
139154
</html>

examples/leaflet/addressService.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@
9898
"<div align='right'>" +
9999
"<input type='button' id='decodeBtn' class='btn btn-primary' value='匹配'/>" +
100100
"</div></div></div>";
101+
handleMapEvent(popup,this._map);
101102
return popup;
102-
}
103+
};
103104
control.addTo(map);
104105

105106
$("#geocode").click(function () {
@@ -173,6 +174,21 @@
173174
codeMarkers = [];
174175
decodeMarkers = [];
175176
}
177+
function handleMapEvent(div, map) {
178+
if (!div || !map) {
179+
return;
180+
}
181+
div.addEventListener('mouseover', function () {
182+
map.dragging.disable();
183+
map.scrollWheelZoom.disable();
184+
map.doubleClickZoom.disable();
185+
});
186+
div.addEventListener('mouseout', function () {
187+
map.dragging.enable();
188+
map.scrollWheelZoom.enable();
189+
map.doubleClickZoom.enable();
190+
});
191+
}
176192
</script>
177193
</body>
178194
</html>

0 commit comments

Comments
 (0)