|
4 | 4 | <head> |
5 | 5 | <!-- <meta charset="UTF-8"> --> |
6 | 6 | <title data-i18n="resources.title_mvtVectorLayer_mapboxStyle_lineStyle"></title> |
7 | | - <script type="text/javascript" include="bootstrap,jquery,colorpicker,ionRangeSlider" src="../js/include-web.js"></script> |
8 | 7 | <!--<script type="text/javascript" src="../../dist/include-openlayers.js"></script>--> |
9 | 8 | <!--当前示例使用 ol-debug 原因:ol.format.MVT 默认坐标系为 3857,最新代码未更新该默认设置,需使用ol-debug,设置 defaultDataProjection 参数,以支持4326底图--> |
10 | 9 | <script src="https://cdn.bootcss.com/openlayers/4.6.5/ol-debug.js"></script> |
|
13 | 12 | <style> |
14 | 13 | ol { |
15 | 14 | list-style: none; |
16 | | - margin-left: -38px; |
| 15 | + margin-left: -30px; |
17 | 16 | } |
18 | 17 |
|
19 | 18 | .ol-popup { |
|
27 | 26 | left: 10px; |
28 | 27 | opacity: 0; |
29 | 28 | transition: opacity 100ms ease-in; |
| 29 | + color: white; |
| 30 | + font-size: 15px; |
| 31 | + font-weight: bold; |
| 32 | + } |
| 33 | + |
| 34 | + #tipsPopup { |
| 35 | + background-color: rgba(0, 60, 136, 0.7); |
| 36 | + color: red; |
| 37 | + display: none; |
| 38 | + padding: 15px; |
| 39 | + color: white; |
| 40 | + font-size: 15px; |
| 41 | + font-weight: bold; |
| 42 | + border-radius: 5px; |
| 43 | + box-shadow: 0px -1px 46px 0px rgba(0, 0, 0, 0.75); |
30 | 44 | } |
31 | 45 |
|
32 | 46 | .editContainer { |
|
39 | 53 | filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2)); |
40 | 54 | box-shadow: 0px 0px 13px 0px rgba(25, 34, 41, 1); |
41 | 55 | background: white; |
42 | | - |
43 | | - |
| 56 | + width: 300px; |
44 | 57 | } |
45 | 58 |
|
46 | 59 | .editContainer>.mainPanelHeader { |
47 | 60 | width: 100%; |
48 | 61 | padding: 8px 15px; |
49 | 62 | background: rgb(0, 131, 203); |
50 | | - font-size: 18px; |
| 63 | + font-size: 17px; |
51 | 64 | font-weight: bold; |
52 | 65 | color: white; |
53 | 66 |
|
|
67 | 80 | color: grey; |
68 | 81 |
|
69 | 82 | } |
70 | | - |
| 83 | + .layerType{ |
| 84 | + margin-top: 20px; |
| 85 | + font-size: 16px; |
| 86 | + font-weight: bold; |
| 87 | + } |
71 | 88 | .borderPanel, |
72 | 89 | .fillPanel { |
73 | 90 | background: white; |
74 | 91 | margin: 10px; |
75 | | - padding: 8px 17px 3px; |
| 92 | + padding: 8px 12px 3px; |
76 | 93 | box-shadow: inset 0px 0px 7px 0px rgba(43, 40, 43, 1); |
77 | 94 | } |
78 | 95 |
|
|
85 | 102 | padding: 8px 0 8px; |
86 | 103 | font-size: 15px; |
87 | 104 | } |
| 105 | + |
| 106 | + .irs { |
| 107 | + height: 40px !important; |
| 108 | + } |
| 109 | + |
| 110 | + .irs-line, |
| 111 | + .irs-line-left, |
| 112 | + .irs-line-mid, |
| 113 | + .irs-line, |
| 114 | + .irs-bar, |
| 115 | + .irs-bar-edge { |
| 116 | + height: 5px !important; |
| 117 | + } |
| 118 | + |
| 119 | + .irs-min, |
| 120 | + .irs-max, |
| 121 | + .irs-from, |
| 122 | + .irs-to, |
| 123 | + .irs-single { |
| 124 | + font-size: 10px !important; |
| 125 | + } |
| 126 | + |
| 127 | + .irs-slider { |
| 128 | + top: 27px !important; |
| 129 | + width: 15px !important; |
| 130 | + height: 15px !important; |
| 131 | + } |
| 132 | + |
| 133 | + .alertContainer { |
| 134 | + width: 100%; |
| 135 | + text-align: center; |
| 136 | + position: absolute; |
| 137 | + top:10px; |
| 138 | + } |
| 139 | + .alertContainer > .alert{ |
| 140 | + margin: auto; |
| 141 | + width: 300px; |
| 142 | + } |
88 | 143 | </style> |
89 | 144 | </head> |
90 | 145 |
|
|
93 | 148 | <div id="popup" class="ol-popup"> |
94 | 149 | <div id="popup-content"></div> |
95 | 150 | </div> |
| 151 | + <div id="tipsPopup"> |
| 152 | + <span data-i18n="resources.text_tipsPopup_subtext"></span> |
| 153 | + </div> |
| 154 | + <div class="alertContainer"> |
| 155 | + <div class="alert alert-info alert-dismissible" role="alert"> |
| 156 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
| 157 | + <span aria-hidden="true">×</span> |
| 158 | + </button> |
| 159 | + <strong data-i18n="resources.text_alert_subtext"></strong> |
| 160 | + </div> |
| 161 | +</div> |
96 | 162 | <div class="editContainer" id="editorContainer"> |
97 | 163 | <div class="mainPanelHeader"> |
98 | 164 | <span data-i18n="resources.text_LineStyleEditor"></span> |
| 165 | + <span id="layer_name"></span> |
99 | 166 | <span class="closeButton" id="closeButton">×</span> |
| 167 | + |
100 | 168 | </div> |
101 | 169 | <div class="editPanel"> |
102 | 170 | <div class="borderPanel"> |
103 | 171 | <div class="borderPanelHeader"> |
104 | | - <span data-i18n="resources.text_lineBorderLayer"></span> |
105 | | - <span id="border_layers_id"></span> |
| 172 | + <span data-i18n="resources.text_lineBorderLayer" class="layerType"></span> |
| 173 | + <span id="border_layers_id" style="display:none"></span> |
106 | 174 | </div> |
107 | 175 | <ol class="borderPanelList"> |
108 | 176 | <li> |
109 | 177 | <label for="border_input_lineColor" data-i18n="resources.text_lineColor_1"></label> |
110 | | - <input type="text" id="border_input_lineColor" value="" style="width:102px;" /> |
| 178 | + <input type="text" id="border_input_lineColor" value="" style="width:158px;" /> |
111 | 179 | <span> |
112 | 180 | <img src='../img/colorpicker.png' id="border_input_lineColor_pic" style="cursor:pointer" /> |
113 | 181 | </span> |
114 | 182 | </li> |
115 | | - <li> |
| 183 | + <li class="slider"> |
116 | 184 | <label for="border_input_lineOpacity" data-i18n="resources.text_lineOpacity"></label> |
117 | 185 | <input type="text" id="border_input_lineOpacity" name="border_input_lineOpacity"> |
118 | 186 | </li> |
119 | | - <li> |
| 187 | + <li class="slider"> |
120 | 188 | <label for="border_input_lineWidth" data-i18n="resources.text_lineWidth_1"></label> |
121 | 189 | <input type="text" id="border_input_lineWidth" name="border_input_lineWidth"> |
122 | 190 | </li> |
123 | 191 | </ol> |
124 | 192 | </div> |
125 | 193 | <div class="fillPanel"> |
126 | 194 | <div class="fillPanelHeader"> |
127 | | - <span data-i18n="resources.text_lineFillLayer"></span> |
128 | | - <span id="fill_layers_id"></span> |
| 195 | + <span data-i18n="resources.text_lineFillLayer" class="layerType"></span> |
| 196 | + <span id="fill_layers_id" style = "display:none"></span> |
129 | 197 | </div> |
130 | 198 | <ol class="fillPanelList"> |
131 | 199 | <li> |
132 | 200 | <label for="fill_input_lineColor" data-i18n="resources.text_lineColor_1"></label> |
133 | | - <input type="text" id="fill_input_lineColor" value="" style="width:102px;" /> |
| 201 | + <input type="text" id="fill_input_lineColor" value="" style="width:158px;" /> |
134 | 202 | <span> |
135 | 203 | <img src='../img/colorpicker.png' id="fill_input_lineColor_pic" style="cursor:pointer" /> |
136 | 204 | </span> |
137 | 205 | </li> |
138 | | - <li> |
| 206 | + <li class="slider"> |
139 | 207 | <label for="fill_input_lineOpacity" name="fill_input_lineOpacity" data-i18n="resources.text_lineOpacity"></label> |
140 | 208 | <input type="text" id="fill_input_lineOpacity"> |
141 | 209 | </li> |
142 | | - <li> |
| 210 | + <li class="slider"> |
143 | 211 | <label for="fill_input_lineWidth" data-i18n="resources.text_lineWidth_1"></label> |
144 | 212 | <input type="text" id="fill_input_lineWidth" name="fill_input_lineWidth"> |
145 | 213 | </li> |
146 | 214 | </ol> |
147 | 215 | </div> |
148 | 216 | </div> |
149 | 217 | </div> |
| 218 | + <script type="text/javascript" include="bootstrap,jquery,colorpicker,ionRangeSlider" src="../js/include-web.js"></script> |
150 | 219 |
|
151 | 220 | <script type="text/javascript"> |
| 221 | + |
152 | 222 | var url = (window.isLocal ? window.server : "http://54.223.164.155:8090") + |
153 | 223 | "/iserver/services/map-mvt-California/rest/maps/California"; |
154 | 224 | getResolutions = function (zoom, scale, targetMinZoom, targetMaxZoom) { |
|
180 | 250 | }); |
181 | 251 | var container = document.getElementById('popup'); |
182 | 252 | var content = document.getElementById('popup-content'); |
183 | | - var editorContainer = document.getElementById('editorContainer') |
| 253 | + var editorContainer = document.getElementById('editorContainer'); |
| 254 | + var tipsPopupContainer = document.getElementById('tipsPopup'); |
184 | 255 | info = new ol.control.Control({ |
185 | 256 | element: container |
186 | 257 | }); |
|
191 | 262 | editorContainerInfo.setMap(map); |
192 | 263 | map.addControl(info); |
193 | 264 | map.addControl(editorContainerInfo); |
| 265 | + var tipsPopup = new ol.Overlay({ |
| 266 | + element: tipsPopupContainer, |
| 267 | + offset: [15, -50] |
| 268 | + }); |
| 269 | + |
| 270 | + map.addOverlay(tipsPopup); |
194 | 271 | var format = new ol.format.MVT({ |
195 | 272 | featureClass: ol.Feature |
196 | 273 | }); |
|
227 | 304 | if (!features) { |
228 | 305 | content.innerHTML = ''; |
229 | 306 | container.style.opacity = 0; |
| 307 | + tipsPopupContainer.style.display = "none"; |
230 | 308 | return; |
231 | 309 | } |
232 | 310 | content.innerHTML = "Layer: " + features[0].get('layer') + "<br />" + (features[0].get('NAME') ? |
233 | 311 | "Name: " + features[0].get('NAME') : ""); |
234 | 312 | container.style.opacity = 1; |
| 313 | + |
| 314 | + var layerName = features[0].get('layer'); |
| 315 | + var layerStyleArr = style.getStylesBySourceLayer(layerName); |
| 316 | + if (layerStyleArr[0].type !== 'line') { |
| 317 | + tipsPopupContainer.style.display = "none"; |
| 318 | + return; |
| 319 | + } |
| 320 | + |
| 321 | + tipsPopupContainer.style.display = "block"; |
| 322 | + tipsPopup.setPosition(e.coordinate); |
235 | 323 | }); |
236 | 324 |
|
237 | 325 |
|
|
250 | 338 | fillJqObject['lineWidth'] = $("#fill_input_lineWidth"); |
251 | 339 | fillJqObject['pic'] = $("#fill_input_lineColor_pic"); |
252 | 340 |
|
253 | | - |
254 | 341 | // 点击弹出编辑框 |
255 | 342 | map.on('click', function (e) { |
256 | 343 | var features = map.getFeaturesAtPixel(e.pixel); |
|
266 | 353 | // 展示图层信息 |
267 | 354 | function showLayerInfo(layerInfo, jqObject) { |
268 | 355 | var layerStyle = layerInfo.style; |
| 356 | + $('#layer_name').html(layerInfo.layerName); |
269 | 357 | jqObject['id'].html(layerInfo.id); |
270 | 358 | jqObject['lineColor'].val(layerStyle.lineColor); |
271 | 359 | jqObject['lineOpacity'].val(layerStyle.lineOpacity); |
|
0 commit comments