123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title data-i18n="resources.title_saveload"></title>
- <style type="text/css">
- body {
- margin: 0;
- overflow: hidden;
- background: #fff;
- width: 100%;
- height: 100%
- }
- #map {
- position: absolute;
- left: 250px;
- right: 0px;
- width: 100%;
- height: 100%;
- }
- #menu {
- position: absolute;
- float: left;
- background: #ffffff;
- width: 250px;
- height: 100%;
- border: 1px solid #3473b7;
- z-index: 100;
- }
- #toolbar {
- position: absolute;
- top: 50px;
- right: 10px;
- width: 315px;
- text-align: center;
- z-index: 100;
- border-radius: 4px;
- }
-
- #toolbar .panel-title {
- font-size: 16px;
- color: white;
- }
- .input-group {
- margin-bottom: 10px;
- }
- .panel-title {
- font-size: 16px;
- color: #ffffff;
- }
- </style>
- </head>
- <body>
- <div id="toolbar" class="panel panel-primary">
- <div class='panel-heading'>
- <h5 class='panel-title text-center' data-i18n="resources.title_saveload"></h5></div>
- <div class='panel-body content'>
- <div class='panel'>
- <div class='input-group' style="margin-top:15px;margin-left: 50px;">
- <select class="search-query form-control" id="SLT" style="width: 200px"></select>
- </div>
- <div class='input-group' style="margin-left: 20px;">
- <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_load"
- onclick="loadSimulationMap()"/>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_cancelMarker"
- onclick="PlottingDrawCancel()"/>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.text_input_value_clear"
- onclick="PlottingClear()"/>
- <input type="button" class="btn btn-default " data-i18n="[value]resources.btn_save" onclick="save()"/>
- </div>
- <div class='input-group' style="margin-left: 50px;margin-bottom: 15px;">
- <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_saveAs"
- onclick="SaveAsSmlFile()"/>
- <input type="text" id="txt" class='form-control' style="width: 100px;float: right"/>
- </div>
- </div>
- </div>
- </div>
- <div id="menu">
- <div class="easyui-panel" style="position:absolute;top:0px;bottom:0px;left:0px;right:0px;padding:5px; width: 100%;">
- <div class="easyui-tabs" style="width: 100%;height: 100%">
- <div id="plotPanel" data-i18n="[title]resources.text_drawPanel" style="overflow: hidden"></div>
- <div id="stylePanel" data-i18n="[title]resources.text_attributePanel"></div>
- </div>
- </div>
- </div>
- <div id="map"></div>
- <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" include="iclient8c-plot,PlottingPanel"
- src="../../dist/classic/include-classic.js"></script>
- <script>
- var map, plottingLayer, layer, plotting, plotPanel, stylePanel, plottingEdit, drawGraphicObjects = [];
- var select, SMLName = null;
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var mapurl = host + "/iserver/services/map-china400/rest/maps/China_4326";
- var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
- init();
- function init() {
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.LayerSwitcher(),
- new SuperMap.Control.ScaleLine(),
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })]
- });
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", mapurl, {
- transparent: true,
- cacheEnabled: true
- }, {maxResolution: "auto"});
- layer.events.on({"layerInitialized": addLayer});
- //总控类
- plotting = SuperMap.Plotting.getInstance(map, serverUrl);
- sitManager = plotting.getSitDataManager();
- sitManager.events.on({
- "getSMLInfosCompleted": getSMLInfosSucess,
- "getSMLInfosFailed": getSMLInfosFail,
- "openSmlFileCompleted": openSuccess,
- "openSmlFileFailed": openFail,
- "saveSmlFileCompleted": saveSuccess,
- "saveSmlFileFailed": saveFail
- });
- plottingLayer = new SuperMap.Layer.PlottingLayer("标绘图层", serverUrl);
- //空间分析服务地址:目前使用的是服务器默认空间分析地址,可更换成实际使用的空间分析服务地址
- //plottingLayer.spatialAnalystUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
- plottingLayer.style = {
- fillColor: "#66cccc",
- fillOpacity: 0.4,
- strokeColor: "#66cccc",
- strokeOpacity: 1,
- strokeWidth: 3,
- pointRadius: 6
- };
- //态势标绘编辑
- plottingEdit = new SuperMap.Control.PlottingEdit();
- // 绘制标号;
- var drawGraphicObject = new SuperMap.Control.DrawFeature(plottingLayer, SuperMap.Handler.GraphicObject);
- drawGraphicObjects.push(drawGraphicObject);
- //添加态势标绘控件
- map.addControls([plottingEdit, drawGraphicObject]);
- }
- function addLayer() {
- map.addLayers([layer, plottingLayer]);
- map.setCenter(new SuperMap.LonLat(104, 35), 3);
- //创建标绘面板
- plotPanel = new SuperMap.Plotting.PlotPanel("plotPanel", serverUrl, map);
- plotPanel.events.on({"initializeCompleted": initializeCompleted});
- plotPanel.initializeAsync();
- //创建属性面板
- stylePanel = new SuperMap.Plotting.StylePanel("stylePanel");
- stylePanel.addEditLayer(plottingLayer);
- //获取标号的列表
- getSMLInfos();
- }
- function initializeCompleted() {
- if (drawGraphicObjects.length > 0) {
- plotPanel.setDrawFeature(drawGraphicObjects[0]);
- }
- }
- //取消标绘
- function plottingAllDeactivate() {
- for (var i = 0; i < drawGraphicObjects.length; i++) {
- drawGraphicObjects[i].deactivate();
- }
- plottingEdit.deactivate();
- }
- //取消标绘,激活标绘编辑控件
- function PlottingDrawCancel() {
- widgets.alert.clearAlert();
- plottingAllDeactivate();
- plottingEdit.activate();
- }
- function getSMLInfos() {
- sitManager.getSMLInfos(0, 10);
- }
- function getSMLInfosSucess(result) {
- select = document.getElementById("SLT");
- while (select.hasChildNodes()) {
- select.removeChild(select.firstChild);
- }
- for (var i = 0, len = result.length; i < len; i++) {
- var options = document.createElement("option");
- options.setAttribute("value", result[i].SMLFileName);
- options.innerHTML = result[i].SMLFileName;
- select.appendChild(options);
- }
- return false;
- }
- function getSMLInfosFail(result) {
- console.log(result);
- }
- //态势图保存
- function save() {
- widgets.alert.clearAlert();
- plottingAllDeactivate();
- sitManager.saveSmlFile();
- }
- //态势图另存为
- function SaveAsSmlFile() {
- plottingAllDeactivate();
- SMLName = document.getElementById("txt").value;
- if (SMLName.length !== 0) {
- sitManager.saveAsSmlFile(SMLName);
- } else {
- widgets.alert.showAlert(resources.msg_inputName, true);
- }
- }
- function saveSuccess() {
- getSMLInfos();
- }
- function saveFail() {
- }
- //加载态势图
- function loadSimulationMap() {
- widgets.alert.clearAlert();
- var select = document.getElementById("SLT");
- for (var i = 0; i < select.children.length; i++) {
- if (select.children[i].selected) {
- sitManager.openSmlFileOnServer(select.children[i].value);
- }
- }
- }
- function openSuccess() {
- var sitDataLayers = sitManager.getSitDataLayers();
- drawGraphicObjects = [];
- for (var i = 0; i < sitDataLayers.length; i++) {
- drawGraphicObjects.push(sitDataLayers[i].drawGraphicObject);
- stylePanel.addEditLayer(sitDataLayers[i]);
- }
- plotPanel.setDrawFeature(drawGraphicObjects[0]);
- }
- function openFail() {
- console.log("error");
- }
- //清空绘制
- function PlottingClear() {
- widgets.alert.clearAlert();
- plottingAllDeactivate();
- for (var i = 0; i < map.layers.length; i++) {
- if (map.layers[i].CLASS_NAME === "SuperMap.Layer.PlottingLayer") {
- map.layers[i].removeAllFeatures();
- }
- }
- }
- document.onmouseup = function (evt) {
- var evt = evt || window.event;
- if (evt.button === 2) {
- PlottingDrawCancel();
- return false;
- }
- evt.stopPropagation();
- }
- </script>
- </body>
- </html>
|