123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <!--********************************************************************
- * 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>
|