forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOGC_wms.html
More file actions
142 lines (137 loc) · 6.25 KB
/
OGC_wms.html
File metadata and controls
142 lines (137 loc) · 6.25 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
<!--********************************************************************
* Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title data-i18n="resources.title_wms"></title>
<style type="text/css">
.editPane {
position: absolute;
right: 10px;
top: 50px;
text-align: center;
background: #FFF;
z-index: 1000;
width: 300px;
}
</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_wms"></h5>
</div>
<div class='panel-body' id='params'>
<div class='input-group'>
<span style="margin-top: 15px" class='input-group-addon' data-i18n="resources.text_projection"></span>
<select class='form-control selectbtn' id='projectionSelect' name="projectionSelect"
onchange="switchProjection()">
<option value="3857">3857</option>
<option value="4326">4326</option>
</select>
</div>
<p>
<div class='input-group'>
<span style="margin-top: 15px" class='input-group-addon' data-i18n="resources.text_wmsVersion"></span>
<select class='form-control selectbtn' id='versionSelect' name="versionSelect"
onchange="switchProjection()">
<option value="1.3.0">1.3.0</option>
<option value="1.1.1">1.1.1</option>
</select>
</div>
</div>
<div id='mousePositionDiv' class='smCustomControlMousePosition'></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 map, layer, wms1, wms2, wms3, wms4, newHtml, projectionSelect, versionSelect, lastLayer, mapDiv,
host = window.isLocal ? window.server : "https://iserver.supermap.io";
var url1 = host + "/iserver/services/map-china400/wms130/China";
var url2 = host + "/iserver/services/map-china400/wms130/China_4326";
var url3 = host + "/iserver/services/map-china400/wms111/China";
var url4 = host + "/iserver/services/map-china400/wms111/China_4326";
map = new SuperMap.Map('map', {
controls: [new SuperMap.Control.Zoom(),
new SuperMap.Control.Navigation(),
new SuperMap.Control.ScaleLine(),
new SuperMap.Control.LayerSwitcher()
]
});
projectionSelect = document.getElementById("projectionSelect");
versionSelect = document.getElementById("versionSelect");
mapDiv = document.getElementById("map");
switchProjection();
setposition();
addHandler(window, "resize", setposition);
function switchProjection() {
if (lastLayer) {
map.removeLayer(lastLayer);
}
if (versionSelect.value == "1.3.0") {
if (projectionSelect.value == "3857") {
//设置layers图层名称必须是 GetCapabilities 操作返回的文档中声明的Name元素的值,地图图层之间以半角英文逗号进行分隔。最左边的图层在最底,下一个图层放到前一个的上面,依次类推。
//version,请求版本号。现支持”1.1.1”和”1.3.0”。
//设置地图的projection,最大显示范围bounds参数
//初始化WCS图层
wms1 = new SuperMap.Layer.WMS("WMS1", url1, {
layers: "China",
version: '1.3.0'
}, {
projection: "EPSG:3857",
maxExtent: new SuperMap.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
});
switchLayer(wms1);
} else if (projectionSelect.value == "4326") {
wms2 = new SuperMap.Layer.WMS("WMS2", url2, {
layers: "China_4326",
version: '1.3.0'
}, {projection: "EPSG:4326", maxExtent: new SuperMap.Bounds(-180, -90, 180, 90)});
switchLayer(wms2);
}
} else if (versionSelect.value == "1.1.1") {
if (projectionSelect.value == "3857") {
wms3 = new SuperMap.Layer.WMS("WMS3", url3, {
layers: "China",
version: '1.1.1'
}, {
projection: "EPSG:3857",
maxExtent: new SuperMap.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
});
switchLayer(wms3);
} else if (projectionSelect.value == "4326") {
wms4 = new SuperMap.Layer.WMS("WMS4", url4, {
layers: "China_4326",
version: '1.1.1'
}, {projection: "EPSG:4326", maxExtent: new SuperMap.Bounds(-180, -90, 180, 90)});
switchLayer(wms4);
}
}
document.getElementById("mousePositionDiv").innerHTML = newHtml;
}
function switchLayer(wms) {
map.addLayers([wms]);
var center = new SuperMap.LonLat(0, 0);
map.setCenter(center, 1);
lastLayer = wms;
mapDiv.focus();
newHtml = resources.text_currentInfo+"<br>" + resources.text_mapProjection + wms.projection + "<br>"+resources.text_currentVersion + wms.params.VERSION;
}
function addHandler(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else if (element.attachEvent) {
element.attachEvent("on" + type, handler);
} else {
element["on" + type] = handler;
}
}
function setposition() {
var width = map.getSize().w;
document.getElementById("mousePositionDiv").style.left = width / 2 - 100 + "px";
}
</script>
</body>
</html>