forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroler_dragpan.html
More file actions
73 lines (69 loc) · 2.84 KB
/
controler_dragpan.html
File metadata and controls
73 lines (69 loc) · 2.84 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
<!--********************************************************************
* Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title data-i18n="resources.title_dragpan"></title>
<style type="text/css">
.editPane {
position: absolute;
right: 50px;
top: 50px;
text-align: center;
background: #FFF;
z-index: 1000;
}
</style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div class='panel panel-primary editPane' id='editPane' style="z-index: 99999">
<div class='panel-heading'>
<h5 class='panel-title text-center' data-i18n="resources.text_dragpan"></h5>
</div>
<div class='panel-body' id='params'>
<p></p>
<div align='right' class='button-group'>
<input type='button' id='btn1' class='btn btn-primary' data-i18n="[value]resources.text_input_value_dragMap" onclick="activated()"/>
<input type='button' id='btn2' class='btn btn-primary' data-i18n="[value]resources.text_input_value_notDrag" onclick="deactivated()"/>
</div>
</div>
</div>
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "https://iserver.supermap.io";
var map, layerWorld;
var url = host + "/iserver/services/map-world/rest/maps/World";
//初始化地图拖拽控件类
dragPan = new SuperMap.Control.DragPan();
//当该属性为true,拖拽地图时,鼠标移动到地图可视区域外依然有效。默认为false
dragPan.documentDrag = true;
//设置是否使用拖拽动画。默认为false,不使用动画
dragPan.enableKinetic = true;
//执行动画的间隔,默认为10,单位是毫秒
dragPan.kineticInterval = 20;
//初始化地图类,添加地图拖拽控件到Map
map = new SuperMap.Map("map", {
controls: [dragPan]
});
layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url); //获取图层服务地址
layerWorld.events.on({"layerInitialized": addLayer});
//添加地图图层到map
function addLayer() {
map.addLayers([layerWorld]);
map.setCenter(new SuperMap.LonLat(80, 37), 4);
}
//激活控件
function activated() {
dragPan.activate();
}
//注销控件
function deactivated() {
dragPan.deactivate();
}
</script>
</body>
</html>