|
| 1 | +<!--******************************************************************** |
| 2 | +* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved. |
| 3 | +*********************************************************************--> |
| 4 | +<!DOCTYPE html> |
| 5 | +<html> |
| 6 | + <head> |
| 7 | + <meta charset="UTF-8" /> |
| 8 | + <title data-i18n="resources.title_mask"></title> |
| 9 | + |
| 10 | + <style type="text/css"> |
| 11 | + .editPane { |
| 12 | + position: absolute; |
| 13 | + top: 50px; |
| 14 | + right: 50px; |
| 15 | + text-align: center; |
| 16 | + background: #fff; |
| 17 | + z-index: 1000; |
| 18 | + } |
| 19 | + </style> |
| 20 | + </head> |
| 21 | + <body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0"> |
| 22 | + <div class="panel panel-primary editPane" id="editPane" style="z-index: 99999"> |
| 23 | + <div class="panel-heading"> |
| 24 | + <h5 class="panel-title text-center" data-i18n="resources.btn_operate"></h5> |
| 25 | + </div> |
| 26 | + <div class="panel-body" id="params"> |
| 27 | + <p></p> |
| 28 | + <div align="right" class="button-group"> |
| 29 | + <input |
| 30 | + type="button" |
| 31 | + id="btn1" |
| 32 | + class="btn btn-primary" |
| 33 | + data-i18n="[value]resources.text_input_value_addMask" |
| 34 | + onclick="addMask()" |
| 35 | + /> |
| 36 | + <input |
| 37 | + type="button" |
| 38 | + id="btn2" |
| 39 | + class="btn btn-primary" |
| 40 | + data-i18n="[value]resources.text_input_value_removeMask" |
| 41 | + onclick="removeMask()" |
| 42 | + /> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + <div id="map" style="width: 100%; height: 100%"></div> |
| 47 | + <script type="text/javascript" include="bootstrap,widgets" src="../js/include-web.js"></script> |
| 48 | + <script type="text/javascript" include="ol-mapbox-style" src="../../dist/ol/include-ol.js"></script> |
| 49 | + <script type="text/javascript"> |
| 50 | + var map, |
| 51 | + sichuanFeature, |
| 52 | + vectorLayer, |
| 53 | + baseUrl = |
| 54 | + (window.isLocal ? window.server : 'https://iserver.supermap.io') + |
| 55 | + '/iserver/services/map-china400/rest/maps/China', |
| 56 | + url = |
| 57 | + (window.isLocal ? window.server : 'https://iserver.supermap.io') + |
| 58 | + '/iserver/services/map-Population/rest/maps/PopulationDistribution'; |
| 59 | + map = new ol.Map({ |
| 60 | + target: 'map', |
| 61 | + controls: ol.control |
| 62 | + .defaults({ attributionOptions: { collapsed: false } }) |
| 63 | + .extend([new ol.supermap.control.Logo()]), |
| 64 | + view: new ol.View({ |
| 65 | + center: [11523496.18, 3735091.51], |
| 66 | + zoom: 4, |
| 67 | + multiWorld: true |
| 68 | + }) |
| 69 | + }); |
| 70 | + var layer = new ol.layer.Tile({ |
| 71 | + source: new ol.source.TileSuperMapRest({ |
| 72 | + url: baseUrl, |
| 73 | + wrapX: true |
| 74 | + }) |
| 75 | + }); |
| 76 | + map.addLayer(layer); |
| 77 | + var vectorLayer = new ol.layer.Tile({ |
| 78 | + source: new ol.source.TileSuperMapRest({ |
| 79 | + url: url, |
| 80 | + wrapX: true |
| 81 | + }) |
| 82 | + }); |
| 83 | + map.addLayer(vectorLayer); |
| 84 | + function addMask() { |
| 85 | + if (!sichuanFeature) { |
| 86 | + widgets.loader.showLoader(resources.text_add_sicahun_plygon); |
| 87 | + var param = new SuperMap.QueryBySQLParameters({ |
| 88 | + queryParams: { |
| 89 | + name: 'China_Province_pl@China', |
| 90 | + attributeFilter: 'SMID =14' |
| 91 | + } |
| 92 | + }); |
| 93 | + new ol.supermap.QueryService(baseUrl).queryBySQL(param, function (serviceResult) { |
| 94 | + widgets.loader.removeLoader(); |
| 95 | + sichuanFeature = new ol.format.GeoJSON().readFeatures( |
| 96 | + serviceResult.result.recordsets[0].features |
| 97 | + )[0]; |
| 98 | + ol.supermap.Util.setMask(vectorLayer, sichuanFeature); |
| 99 | + }); |
| 100 | + return; |
| 101 | + } else { |
| 102 | + ol.supermap.Util.setMask(vectorLayer, sichuanFeature); |
| 103 | + } |
| 104 | + } |
| 105 | + function removeMask() { |
| 106 | + ol.supermap.Util.unsetMask(vectorLayer); |
| 107 | + } |
| 108 | + </script> |
| 109 | + </body> |
| 110 | +</html> |
0 commit comments