my-openlayer 2.1.5 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/MeasureHandler.d.ts +5 -0
- package/core/MeasureHandler.js +54 -0
- package/package.json +1 -1
package/core/MeasureHandler.d.ts
CHANGED
package/core/MeasureHandler.js
CHANGED
|
@@ -21,6 +21,7 @@ export default class MeasureHandler {
|
|
|
21
21
|
constructor(map) {
|
|
22
22
|
this._draw = null;
|
|
23
23
|
ValidationUtils.validateMap(map);
|
|
24
|
+
this.initStyles();
|
|
24
25
|
this._map = map;
|
|
25
26
|
this.source = new VectorSource();
|
|
26
27
|
this.vector = new VectorLayer({
|
|
@@ -310,4 +311,57 @@ export default class MeasureHandler {
|
|
|
310
311
|
}
|
|
311
312
|
this._tipsCollection = [];
|
|
312
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* 初始化样式
|
|
316
|
+
* @private
|
|
317
|
+
*/
|
|
318
|
+
initStyles() {
|
|
319
|
+
const styleId = 'ol-measure-tooltip-styles';
|
|
320
|
+
if (document.getElementById(styleId)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const style = document.createElement('style');
|
|
324
|
+
style.id = styleId;
|
|
325
|
+
style.innerHTML = `
|
|
326
|
+
.ol-tooltip {
|
|
327
|
+
position: relative;
|
|
328
|
+
background: rgba(0, 0, 0, 0.5);
|
|
329
|
+
border-radius: 4px;
|
|
330
|
+
color: white;
|
|
331
|
+
padding: 4px 8px;
|
|
332
|
+
opacity: 0.7;
|
|
333
|
+
white-space: nowrap;
|
|
334
|
+
font-size: 12px;
|
|
335
|
+
cursor: default;
|
|
336
|
+
user-select: none;
|
|
337
|
+
border: 1px solid #cccccc;
|
|
338
|
+
text-shadow: 1px 1px 2px #000;
|
|
339
|
+
}
|
|
340
|
+
.ol-tooltip-measure {
|
|
341
|
+
opacity: 1;
|
|
342
|
+
font-weight: bold;
|
|
343
|
+
}
|
|
344
|
+
.ol-tooltip-static {
|
|
345
|
+
background-color: #ffcc33;
|
|
346
|
+
color: black;
|
|
347
|
+
border: 1px solid white;
|
|
348
|
+
text-shadow: none;
|
|
349
|
+
}
|
|
350
|
+
.ol-tooltip-measure:before,
|
|
351
|
+
.ol-tooltip-static:before {
|
|
352
|
+
border-top: 6px solid rgba(0, 0, 0, 0.5);
|
|
353
|
+
border-right: 6px solid transparent;
|
|
354
|
+
border-left: 6px solid transparent;
|
|
355
|
+
content: "";
|
|
356
|
+
position: absolute;
|
|
357
|
+
bottom: -6px;
|
|
358
|
+
margin-left: -7px;
|
|
359
|
+
left: 50%;
|
|
360
|
+
}
|
|
361
|
+
.ol-tooltip-static:before {
|
|
362
|
+
border-top-color: #ffcc33;
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
365
|
+
document.head.appendChild(style);
|
|
366
|
+
}
|
|
313
367
|
}
|