@summeruse/ol 0.1.0 → 0.1.1-beta.0

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/CHANGELOG.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # @summeruse/ol
2
2
 
3
- ## 0.1.0
3
+ ## 0.1.1-beta.0
4
4
 
5
- ### Minor Changes
5
+ ### Patch Changes
6
6
 
7
- - 更新 0.1.0 正式版
7
+ - c26ae5a: 重构 useGraticule 以支持更灵活的样式配置
8
8
 
9
- ## 0.0.1
9
+ ## 0.1.0
10
10
 
11
- ### Patch Changes
11
+ ### Minor Changes
12
12
 
13
13
  - 8e34a3f: 添加 useDrawLineString useDrawPolygon
14
14
  - b6b95dc: 添加创建几何要素的实用函数
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { defineComponent as Y, ref as v, onMounted as D, createBlock as he, openBlock as U, unref as R, shallowRef as Ce, withCtx as ke, createVNode as Fe, watch as f, provide as Me, createElementBlock as Ae, renderSlot as Te, computed as pe, render as z, onUnmounted as Se, toValue as _e } from "vue";
1
+ import { defineComponent as Y, ref as v, onMounted as D, createBlock as pe, openBlock as U, unref as R, shallowRef as Ce, withCtx as ke, createVNode as Fe, watch as d, provide as Me, createElementBlock as Ae, renderSlot as Te, computed as he, render as z, onUnmounted as Se, toValue as _e } from "vue";
2
2
  import { NDropdown as Re, NPopover as ze } from "naive-ui";
3
3
  import { RenderVNode as Ze } from "@summeruse/common";
4
4
  import { Map as Ge, View as Be, Feature as H, Overlay as Z } from "ol";
5
- import { Zoom as ne, Attribution as re, Rotate as oe, FullScreen as ie, OverviewMap as ae, ScaleLine as ce } from "ol/control";
6
- import { DragPan as le, MouseWheelZoom as se, DoubleClickZoom as ue, PinchRotate as fe, PinchZoom as de, DragRotate as me, KeyboardPan as ye, KeyboardZoom as we, Draw as Ee, Modify as Oe } from "ol/interaction";
5
+ import { Zoom as ne, Attribution as oe, Rotate as re, FullScreen as ie, OverviewMap as ae, ScaleLine as ce } from "ol/control";
6
+ import { DragPan as le, MouseWheelZoom as se, DoubleClickZoom as ue, PinchRotate as fe, PinchZoom as de, DragRotate as me, KeyboardPan as ye, KeyboardZoom as we, Draw as Oe, Modify as Ee } from "ol/interaction";
7
7
  import { Point as De, LineString as W, Polygon as $, Circle as Ne, MultiPoint as je, MultiLineString as Ve, MultiPolygon as We } from "ol/geom";
8
8
  import Q from "ol/layer/Vector";
9
9
  import q from "ol/source/Vector";
10
10
  import { destination as $e, lineString as Xe, length as Ke, area as Ye, polygon as Ue, bearing as He, midpoint as Qe } from "@turf/turf";
11
11
  import { Circle as qe, Stroke as F, Fill as G, Text as Je, Icon as et, Style as tt } from "ol/style";
12
12
  import { Tile as J, Graticule as ve } from "ol/layer";
13
- import { XYZ as nt, BingMaps as rt, OSM as ot } from "ol/source";
13
+ import { XYZ as nt, BingMaps as ot, OSM as rt } from "ol/source";
14
14
  import { transform as xe, transformExtent as be } from "ol/proj";
15
15
  const Rt = /* @__PURE__ */ Y({
16
16
  __name: "index",
@@ -24,34 +24,34 @@ const Rt = /* @__PURE__ */ Y({
24
24
  x: 0,
25
25
  y: 0
26
26
  });
27
- function o() {
27
+ function r() {
28
28
  i.value.visible = !1;
29
29
  }
30
30
  const a = v();
31
31
  D(() => {
32
- const d = n.getViewport();
33
- d && (d.oncontextmenu = (s) => {
32
+ const f = n.getViewport();
33
+ f && (f.oncontextmenu = (s) => {
34
34
  s.preventDefault();
35
- const l = n.getEventPixel(s), p = n.getEventCoordinate(s), w = n.getFeaturesAtPixel(l);
36
- a.value = e.createOptions({ event: s, pixel: l, coordinate: p, features: w }), i.value = {
35
+ const l = n.getEventPixel(s), h = n.getEventCoordinate(s), w = n.getFeaturesAtPixel(l);
36
+ a.value = e.createOptions({ event: s, pixel: l, coordinate: h, features: w }), i.value = {
37
37
  visible: !0,
38
38
  x: s.clientX,
39
39
  y: s.clientY
40
40
  };
41
41
  });
42
42
  });
43
- function c(d, s) {
43
+ function c(f, s) {
44
44
  const { onClick: l } = s;
45
45
  l && l(), i.value.visible = !1;
46
46
  }
47
- return (d, s) => (U(), he(R(Re), {
47
+ return (f, s) => (U(), pe(R(Re), {
48
48
  placement: "bottom-start",
49
49
  trigger: "manual",
50
50
  show: a.value && a.value.length > 0 && i.value.visible,
51
51
  x: i.value.x,
52
52
  y: i.value.y,
53
53
  options: a.value,
54
- "on-clickoutside": o,
54
+ "on-clickoutside": r,
55
55
  onSelect: c
56
56
  }, null, 8, ["show", "x", "y", "options"]));
57
57
  }
@@ -66,23 +66,23 @@ const Rt = /* @__PURE__ */ Y({
66
66
  visible: !1,
67
67
  x: 0,
68
68
  y: 0
69
- }), i = Ce(), o = v("bottom-start"), a = v(!1), c = v(!1);
69
+ }), i = Ce(), r = v("bottom-start"), a = v(!1), c = v(!1);
70
70
  return D(() => {
71
- var d;
72
- (d = e.olMap) == null || d.on("pointermove", (s) => {
73
- const l = e.olMap.getFeaturesAtPixel(s.pixel), { clientX: p, clientY: w } = s.originalEvent;
71
+ var f;
72
+ (f = e.olMap) == null || f.on("pointermove", (s) => {
73
+ const l = e.olMap.getFeaturesAtPixel(s.pixel), { clientX: h, clientY: w } = s.originalEvent;
74
74
  n.value.visible = !1;
75
75
  const m = e.createOptions({
76
76
  pixel: s.pixel,
77
77
  coordinate: s.coordinate,
78
78
  features: l
79
79
  });
80
- m && (i.value = m.content, o.value = m.placement || "bottom-start", c.value = m.showArrow || !1, a.value = m.raw || !1, n.value.visible = !0, n.value.x = p, n.value.y = w);
80
+ m && (i.value = m.content, r.value = m.placement || "bottom-start", c.value = m.showArrow || !1, a.value = m.raw || !1, n.value.visible = !0, n.value.x = h, n.value.y = w);
81
81
  });
82
- }), (d, s) => (U(), he(R(ze), {
82
+ }), (f, s) => (U(), pe(R(ze), {
83
83
  "show-arrow": c.value,
84
84
  raw: a.value,
85
- placement: o.value,
85
+ placement: r.value,
86
86
  show: n.value.visible,
87
87
  x: n.value.x,
88
88
  y: n.value.y,
@@ -123,92 +123,92 @@ const Rt = /* @__PURE__ */ Y({
123
123
  altShiftDragRotate: { type: Boolean }
124
124
  },
125
125
  setup(t, { expose: e }) {
126
- const n = t, i = v(), o = n.olMap, a = new Be({
126
+ const n = t, i = v(), r = n.olMap, a = new Be({
127
127
  projection: n.projection,
128
128
  extent: n.extent
129
129
  });
130
- o.setView(a), f(() => n.zoom, (r) => {
131
- a.setZoom(r);
130
+ r.setView(a), d(() => n.zoom, (o) => {
131
+ a.setZoom(o);
132
132
  }, {
133
133
  immediate: !0
134
- }), f(() => n.center, (r) => {
135
- a.setCenter(r);
134
+ }), d(() => n.center, (o) => {
135
+ a.setCenter(o);
136
136
  }, {
137
137
  immediate: !0
138
- }), f(() => n.constrainResolution, (r) => {
139
- a.setConstrainResolution(r);
138
+ }), d(() => n.constrainResolution, (o) => {
139
+ a.setConstrainResolution(o);
140
140
  }, {
141
141
  immediate: !0
142
- }), f(() => n.minZoom, (r) => {
143
- r && a.setMinZoom(r);
142
+ }), d(() => n.minZoom, (o) => {
143
+ o && a.setMinZoom(o);
144
144
  }, {
145
145
  immediate: !0
146
- }), f(() => n.maxZoom, (r) => {
147
- r && a.setMaxZoom(r);
146
+ }), d(() => n.maxZoom, (o) => {
147
+ o && a.setMaxZoom(o);
148
148
  }, {
149
149
  immediate: !0
150
- }), f(i, (r) => {
151
- r && o.setTarget(r);
150
+ }), d(i, (o) => {
151
+ o && r.setTarget(o);
152
152
  }), e({
153
- olMap: o
154
- }), Me(it, o);
155
- const c = o.getControls().getArray(), d = c.find((r) => r instanceof ne) || new ne(), s = c.find((r) => r instanceof re) || new re(), l = c.find((r) => r instanceof oe) || new oe(), p = c.find((r) => r instanceof ie) || new ie(), w = c.find((r) => r instanceof ae) || new ae(), m = c.find((r) => r instanceof ce) || new ce();
156
- f(() => n.showZoom, (r) => {
157
- d.setMap(r ? o : null);
153
+ olMap: r
154
+ }), Me(it, r);
155
+ const c = r.getControls().getArray(), f = c.find((o) => o instanceof ne) || new ne(), s = c.find((o) => o instanceof oe) || new oe(), l = c.find((o) => o instanceof re) || new re(), h = c.find((o) => o instanceof ie) || new ie(), w = c.find((o) => o instanceof ae) || new ae(), m = c.find((o) => o instanceof ce) || new ce();
156
+ d(() => n.showZoom, (o) => {
157
+ f.setMap(o ? r : null);
158
158
  }, {
159
159
  immediate: !0
160
- }), f(() => n.showAttribution, (r) => {
161
- s.setMap(r ? o : null);
160
+ }), d(() => n.showAttribution, (o) => {
161
+ s.setMap(o ? r : null);
162
162
  }, {
163
163
  immediate: !0
164
- }), f(() => n.showRotate, (r) => {
165
- l.setMap(r ? o : null);
164
+ }), d(() => n.showRotate, (o) => {
165
+ l.setMap(o ? r : null);
166
166
  }, {
167
167
  immediate: !0
168
- }), f(() => n.showFullScreen, (r) => {
169
- p.setMap(r ? o : null);
168
+ }), d(() => n.showFullScreen, (o) => {
169
+ h.setMap(o ? r : null);
170
170
  }, {
171
171
  immediate: !0
172
- }), f(() => n.showOverview, (r) => {
173
- w.setMap(r ? o : null);
172
+ }), d(() => n.showOverview, (o) => {
173
+ w.setMap(o ? r : null);
174
174
  }, {
175
175
  immediate: !0
176
- }), f(() => n.showScale, (r) => {
177
- m.setMap(r ? o : null);
176
+ }), d(() => n.showScale, (o) => {
177
+ m.setMap(o ? r : null);
178
178
  }, {
179
179
  immediate: !0
180
180
  });
181
- const y = o.getInteractions().getArray(), S = y.find((r) => r instanceof le) || new le(), P = y.find((r) => r instanceof se) || new se(), E = y.find((r) => r instanceof ue) || new ue(), O = y.find((r) => r instanceof fe) || new fe(), x = y.find((r) => r instanceof de) || new de(), I = y.find((r) => r instanceof me) || new me(), u = y.find((r) => r instanceof ye) || new ye(), g = y.find((r) => r instanceof we) || new we();
182
- return o.removeInteraction(S), o.addInteraction(S), o.removeInteraction(P), o.addInteraction(P), o.removeInteraction(E), o.addInteraction(E), o.removeInteraction(O), o.addInteraction(O), o.removeInteraction(x), o.addInteraction(x), o.removeInteraction(I), o.addInteraction(I), o.removeInteraction(u), o.removeInteraction(g), f(() => n.dragPan, (r) => {
183
- S.setActive(r);
181
+ const y = r.getInteractions().getArray(), S = y.find((o) => o instanceof le) || new le(), P = y.find((o) => o instanceof se) || new se(), O = y.find((o) => o instanceof ue) || new ue(), E = y.find((o) => o instanceof fe) || new fe(), x = y.find((o) => o instanceof de) || new de(), I = y.find((o) => o instanceof me) || new me(), u = y.find((o) => o instanceof ye) || new ye(), g = y.find((o) => o instanceof we) || new we();
182
+ return r.removeInteraction(S), r.addInteraction(S), r.removeInteraction(P), r.addInteraction(P), r.removeInteraction(O), r.addInteraction(O), r.removeInteraction(E), r.addInteraction(E), r.removeInteraction(x), r.addInteraction(x), r.removeInteraction(I), r.addInteraction(I), r.removeInteraction(u), r.removeInteraction(g), d(() => n.dragPan, (o) => {
183
+ S.setActive(o);
184
184
  }, {
185
185
  immediate: !0
186
- }), f(() => n.mouseWheelZoom, (r) => {
187
- P.setActive(r);
186
+ }), d(() => n.mouseWheelZoom, (o) => {
187
+ P.setActive(o);
188
188
  }, {
189
189
  immediate: !0
190
- }), f(() => n.doubleClickZoom, (r) => {
191
- E.setActive(r);
190
+ }), d(() => n.doubleClickZoom, (o) => {
191
+ O.setActive(o);
192
192
  }, {
193
193
  immediate: !0
194
- }), f(() => n.pinchRotate, (r) => {
195
- O.setActive(r);
194
+ }), d(() => n.pinchRotate, (o) => {
195
+ E.setActive(o);
196
196
  }, {
197
197
  immediate: !0
198
- }), f(() => n.pinchZoom, (r) => {
199
- x.setActive(r);
198
+ }), d(() => n.pinchZoom, (o) => {
199
+ x.setActive(o);
200
200
  }, {
201
201
  immediate: !0
202
- }), f(() => n.altShiftDragRotate, (r) => {
203
- I.setActive(r);
202
+ }), d(() => n.altShiftDragRotate, (o) => {
203
+ I.setActive(o);
204
204
  }, {
205
205
  immediate: !0
206
- }), (r, h) => (U(), Ae("div", {
206
+ }), (o, p) => (U(), Ae("div", {
207
207
  ref_key: "mapRef",
208
208
  ref: i
209
209
  }, [
210
- Te(r.$slots, "default", {
211
- olMap: R(o),
210
+ Te(o.$slots, "default", {
211
+ olMap: R(r),
212
212
  mapRef: i.value
213
213
  })
214
214
  ], 512));
@@ -255,22 +255,22 @@ function st(t) {
255
255
  });
256
256
  }
257
257
  function ut(t) {
258
- const { fillOptions: e, strokeOptions: n, backgroundFillOptions: i, backgroundStrokeOptions: o, ...a } = t;
258
+ const { fillOptions: e, strokeOptions: n, backgroundFillOptions: i, backgroundStrokeOptions: r, ...a } = t;
259
259
  return new Je({
260
260
  ...a,
261
261
  fill: e ? new G(e) : void 0,
262
262
  stroke: n ? new F(n) : void 0,
263
263
  backgroundFill: i ? new G(i) : void 0,
264
- backgroundStroke: o ? new F(o) : void 0
264
+ backgroundStroke: r ? new F(r) : void 0
265
265
  });
266
266
  }
267
267
  function L(t) {
268
- const { fillOptions: e, strokeOptions: n, iconOptions: i, circleOptions: o, textOptions: a, ...c } = t, d = e ? new G(e) : void 0, s = n ? new F(n) : void 0, l = i ? new et(i) : void 0, p = o ? st(o) : void 0, w = a ? ut(a) : void 0;
268
+ const { fillOptions: e, strokeOptions: n, iconOptions: i, circleOptions: r, textOptions: a, ...c } = t, f = e ? new G(e) : void 0, s = n ? new F(n) : void 0, l = i ? new et(i) : void 0, h = r ? st(r) : void 0, w = a ? ut(a) : void 0;
269
269
  return new tt({
270
270
  ...c,
271
- fill: d,
271
+ fill: f,
272
272
  stroke: s,
273
- image: l || p,
273
+ image: l || h,
274
274
  text: w
275
275
  });
276
276
  }
@@ -351,16 +351,16 @@ function Ut(t, e) {
351
351
  geometry: n
352
352
  });
353
353
  }
354
- function ht(t) {
355
- const { type: e = "img", projection: n = ge, key: i } = t, o = t.url || "https://t{0-4}.tianditu.gov.cn", a = `&tk=${i}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
356
- return `${o}/${e}_${n === lt ? "c" : n === ge ? "w" : "c"}/wmts?LAYER=${e}${a}`;
354
+ function pt(t) {
355
+ const { type: e = "img", projection: n = ge, key: i } = t, r = t.url || "https://t{0-4}.tianditu.gov.cn", a = `&tk=${i}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
356
+ return `${r}/${e}_${n === lt ? "c" : n === ge ? "w" : "c"}/wmts?LAYER=${e}${a}`;
357
357
  }
358
358
  function Ht(t) {
359
359
  const { zIndex: e, projection: n, className: i } = t;
360
360
  return new J({
361
361
  className: i,
362
362
  source: new nt({
363
- url: ht(t),
363
+ url: pt(t),
364
364
  projection: n,
365
365
  crossOrigin: "Anonymous"
366
366
  }),
@@ -375,7 +375,7 @@ function Qt({
375
375
  }) {
376
376
  return new J({
377
377
  className: i,
378
- source: new rt({
378
+ source: new ot({
379
379
  key: n,
380
380
  imagerySet: t,
381
381
  placeholderTiles: !1
@@ -386,20 +386,20 @@ function Qt({
386
386
  function qt(t) {
387
387
  return new J({
388
388
  className: t == null ? void 0 : t.className,
389
- source: new ot({
389
+ source: new rt({
390
390
  crossOrigin: "Anonymous"
391
391
  }),
392
392
  zIndex: t == null ? void 0 : t.zIndex
393
393
  });
394
394
  }
395
395
  function Jt(t) {
396
- const { styleOptions: e, ...n } = t || {}, i = e ? L(e) : void 0, o = new q(), a = new Q({
397
- source: o,
396
+ const { styleOptions: e, ...n } = t || {}, i = e ? L(e) : void 0, r = new q(), a = new Q({
397
+ source: r,
398
398
  ...n,
399
399
  style: i || n.style
400
400
  });
401
401
  return {
402
- source: o,
402
+ source: r,
403
403
  layer: a
404
404
  };
405
405
  }
@@ -407,10 +407,10 @@ function ee(t) {
407
407
  return xe(t, _, T);
408
408
  }
409
409
  const en = ee;
410
- function pt(t) {
410
+ function ht(t) {
411
411
  return xe(t, T, _);
412
412
  }
413
- const tn = pt;
413
+ const tn = ht;
414
414
  function St(t) {
415
415
  return be(t, _, T);
416
416
  }
@@ -418,10 +418,10 @@ const nn = St;
418
418
  function te(t) {
419
419
  return be(t, T, _);
420
420
  }
421
- const rn = te;
422
- function on(t, e, n = 60) {
423
- const i = [], o = 360 / n;
424
- for (let a = -180; a < 180; a = a + o)
421
+ const on = te;
422
+ function rn(t, e, n = 60) {
423
+ const i = [], r = 360 / n;
424
+ for (let a = -180; a < 180; a = a + r)
425
425
  i.push(at(t, e, a));
426
426
  return [i];
427
427
  }
@@ -430,21 +430,21 @@ function B(t) {
430
430
  return e.innerHTML = t, e.style.cursor = "pointer", e.style.userSelect = "none", e.style.backgroundColor = "red", e.style.color = "white", e.style.borderRadius = "5px", e.style.padding = "0 5px", e.style.fontSize = "12px", e.style.border = "2px solid white", e;
431
431
  }
432
432
  function an(t, e) {
433
- const n = v(!0), i = v([]), o = pe(() => i.value.map((u) => u.getGeometry().getCoordinates())), a = new q(), c = e.styleOptions ? L(e.styleOptions) : e == null ? void 0 : e.style, d = new Q({
433
+ const n = v(!0), i = v([]), r = he(() => i.value.map((u) => u.getGeometry().getCoordinates())), a = new q(), c = e.styleOptions ? L(e.styleOptions) : e == null ? void 0 : e.style, f = new Q({
434
434
  source: a,
435
435
  style: c,
436
436
  zIndex: e == null ? void 0 : e.zIndex
437
437
  });
438
- t.addLayer(d);
439
- const s = e.drawStyleOptions ? L(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, l = new Ee({
438
+ t.addLayer(f);
439
+ const s = e.drawStyleOptions ? L(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, l = new Oe({
440
440
  source: a,
441
441
  style: s || c,
442
442
  type: "LineString"
443
443
  });
444
444
  l.setActive(!1);
445
- const p = e.modifyStyleOptions ? L(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, w = new Oe({
445
+ const h = e.modifyStyleOptions ? L(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, w = new Ee({
446
446
  source: a,
447
- style: p || c
447
+ style: h || c
448
448
  }), m = /* @__PURE__ */ new Set();
449
449
  t.addInteraction(l), D(() => {
450
450
  t.addInteraction(w);
@@ -460,15 +460,15 @@ function an(t, e) {
460
460
  };
461
461
  a.on("change", () => {
462
462
  y(), a.getFeatures().forEach((u) => {
463
- const g = u.getGeometry(), r = Le(te(g.getExtent()));
464
- let h = document.createElement("div");
465
- e.deleteFeatureLabel ? z(e.deleteFeatureLabel, h) : h = B("删除线"), h.addEventListener("click", () => {
463
+ const g = u.getGeometry(), o = Le(te(g.getExtent()));
464
+ let p = document.createElement("div");
465
+ e.deleteFeatureLabel ? z(e.deleteFeatureLabel, p) : p = B("删除线"), p.addEventListener("click", () => {
466
466
  a.removeFeature(u);
467
467
  });
468
468
  const M = new Z({
469
- position: ee(r),
469
+ position: ee(o),
470
470
  positioning: "center-center",
471
- element: h
471
+ element: p
472
472
  });
473
473
  m.add(M), t.addOverlay(M);
474
474
  const C = g.getCoordinates();
@@ -492,57 +492,57 @@ function an(t, e) {
492
492
  i.value = a.getFeatures();
493
493
  });
494
494
  const S = () => {
495
- y(), t.removeLayer(d), t.removeInteraction(l), t.removeInteraction(w);
495
+ y(), t.removeLayer(f), t.removeInteraction(l), t.removeInteraction(w);
496
496
  }, P = () => {
497
497
  e.size && i.value.length >= e.size || l.setActive(!0);
498
- }, E = () => {
498
+ }, O = () => {
499
499
  l.setActive(!1);
500
- }, O = (u) => {
500
+ }, E = (u) => {
501
501
  a.clear(), u.forEach((g) => {
502
502
  if (g.length < 2)
503
503
  return;
504
- const r = new H({
504
+ const o = new H({
505
505
  geometry: new W(g)
506
506
  });
507
- a.addFeature(r);
507
+ a.addFeature(o);
508
508
  });
509
509
  }, x = () => {
510
- O(e.defaultCoordinates || []);
510
+ E(e.defaultCoordinates || []);
511
511
  };
512
512
  x();
513
513
  const I = () => {
514
- a.clear(), E();
514
+ a.clear(), O();
515
515
  };
516
516
  return Se(() => {
517
517
  S();
518
518
  }), {
519
519
  inDraw: n,
520
520
  start: P,
521
- stop: E,
521
+ stop: O,
522
522
  clear: I,
523
- setFeatures: O,
523
+ setFeatures: E,
524
524
  reset: x,
525
525
  features: i,
526
- coordinates: o,
526
+ coordinates: r,
527
527
  destroy: S
528
528
  };
529
529
  }
530
530
  function cn(t, e) {
531
- const n = v(!0), i = v([]), o = pe(() => i.value.map((u) => u.getGeometry().getCoordinates())), a = e.styleOptions ? L(e.styleOptions) : e == null ? void 0 : e.style, c = new q(), d = new Q({
531
+ const n = v(!0), i = v([]), r = he(() => i.value.map((u) => u.getGeometry().getCoordinates())), a = e.styleOptions ? L(e.styleOptions) : e == null ? void 0 : e.style, c = new q(), f = new Q({
532
532
  source: c,
533
533
  style: a,
534
534
  zIndex: e == null ? void 0 : e.zIndex
535
535
  });
536
- t.addLayer(d);
537
- const s = e.drawStyleOptions ? L(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, l = new Ee({
536
+ t.addLayer(f);
537
+ const s = e.drawStyleOptions ? L(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, l = new Oe({
538
538
  source: c,
539
539
  style: s || a,
540
540
  type: "Polygon"
541
541
  });
542
542
  l.setActive(!1);
543
- const p = e.modifyStyleOptions ? L(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, w = new Oe({
543
+ const h = e.modifyStyleOptions ? L(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, w = new Ee({
544
544
  source: c,
545
- style: p || a
545
+ style: h || a
546
546
  }), m = /* @__PURE__ */ new Set();
547
547
  t.addInteraction(l), D(() => {
548
548
  t.addInteraction(w);
@@ -558,15 +558,15 @@ function cn(t, e) {
558
558
  };
559
559
  c.on("change", () => {
560
560
  y(), c.getFeatures().forEach((u) => {
561
- const g = u.getGeometry(), r = Le(te(g.getExtent()));
562
- let h = document.createElement("div");
563
- e.deleteFeatureLabel ? z(e.deleteFeatureLabel, h) : h = B("删除区域"), h.addEventListener("click", () => {
561
+ const g = u.getGeometry(), o = Le(te(g.getExtent()));
562
+ let p = document.createElement("div");
563
+ e.deleteFeatureLabel ? z(e.deleteFeatureLabel, p) : p = B("删除区域"), p.addEventListener("click", () => {
564
564
  c.removeFeature(u);
565
565
  });
566
566
  const M = new Z({
567
- position: ee(r),
567
+ position: ee(o),
568
568
  positioning: "center-center",
569
- element: h
569
+ element: p
570
570
  });
571
571
  m.add(M), t.addOverlay(M);
572
572
  const C = g.getCoordinates()[0];
@@ -590,61 +590,55 @@ function cn(t, e) {
590
590
  i.value = c.getFeatures();
591
591
  });
592
592
  const S = () => {
593
- y(), t.removeLayer(d), t.removeInteraction(l), t.removeInteraction(w);
593
+ y(), t.removeLayer(f), t.removeInteraction(l), t.removeInteraction(w);
594
594
  }, P = () => {
595
595
  e.size && i.value.length >= e.size || l.setActive(!0);
596
- }, E = () => {
596
+ }, O = () => {
597
597
  l.setActive(!1);
598
- }, O = (u) => {
598
+ }, E = (u) => {
599
599
  c.clear(), u == null || u.forEach((g) => {
600
- g.forEach((r) => {
601
- if (r.length < 2)
600
+ g.forEach((o) => {
601
+ if (o.length < 2)
602
602
  return;
603
- r[0] !== r[r.length - 1] && r.push(r[0]);
604
- const h = new H({
605
- geometry: new $([r])
603
+ o[0] !== o[o.length - 1] && o.push(o[0]);
604
+ const p = new H({
605
+ geometry: new $([o])
606
606
  });
607
- c.addFeature(h);
607
+ c.addFeature(p);
608
608
  });
609
609
  });
610
610
  }, x = () => {
611
- O(e.defaultCoordinates);
611
+ E(e.defaultCoordinates);
612
612
  };
613
613
  x();
614
614
  const I = () => {
615
- c.clear(), E();
615
+ c.clear(), O();
616
616
  };
617
617
  return Se(() => {
618
618
  S();
619
619
  }), {
620
620
  inDraw: n,
621
621
  start: P,
622
- stop: E,
622
+ stop: O,
623
623
  clear: I,
624
- setFeatures: O,
624
+ setFeatures: E,
625
625
  reset: x,
626
626
  features: i,
627
- coordinates: o,
627
+ coordinates: r,
628
628
  destroy: S
629
629
  };
630
630
  }
631
631
  function ln(t) {
632
- const e = v(t.defaultShow || !1);
633
- let n = new ve({
634
- strokeStyle: t.strokeStyle || new F({
635
- color: "#000",
636
- width: 1.5,
637
- lineDash: [4, 4]
638
- }),
639
- showLabels: !0,
640
- wrapX: !1,
641
- zIndex: 1
632
+ const e = v(t.defaultShow || !1), { strokeStyleOption: n, strokeStyle: i, ...r } = t.graticuleOptions || {}, a = n ? new F(n) : i;
633
+ let c = new ve({
634
+ ...r,
635
+ strokeStyle: a
642
636
  });
643
- return f(
637
+ return d(
644
638
  e,
645
- (i) => {
646
- if (n.setMap(null), i) {
647
- n = new ve({
639
+ (f) => {
640
+ if (c.setMap(null), f) {
641
+ c = new ve({
648
642
  strokeStyle: new F({
649
643
  color: "#555",
650
644
  width: 1.5,
@@ -654,8 +648,8 @@ function ln(t) {
654
648
  wrapX: !1,
655
649
  zIndex: 1
656
650
  });
657
- const o = _e(t.olMap);
658
- o && n.setMap(o);
651
+ const s = _e(t.olMap);
652
+ s && c.setMap(s);
659
653
  }
660
654
  },
661
655
  {
@@ -672,13 +666,13 @@ function sn(t) {
672
666
  n.forEach((i) => {
673
667
  t.olMap.addLayer(i);
674
668
  });
675
- }), f(
669
+ }), d(
676
670
  e,
677
671
  () => {
678
672
  Object.entries(t.layers).forEach(([n, i]) => {
679
- const o = n === e.value;
673
+ const r = n === e.value;
680
674
  i.forEach((a) => {
681
- a.setVisible(o);
675
+ a.setVisible(r);
682
676
  });
683
677
  });
684
678
  },
@@ -689,7 +683,7 @@ function sn(t) {
689
683
  }
690
684
  export {
691
685
  T as EPSG_3857,
692
- rn as EPSG_3857ExtentToEPSG_4326,
686
+ on as EPSG_3857ExtentToEPSG_4326,
693
687
  tn as EPSG_3857ToEPSG_4326,
694
688
  _ as EPSG_4326,
695
689
  nn as EPSG_4326ExtentToEPSG_3857,
@@ -727,12 +721,12 @@ export {
727
721
  Le as getExtentCenter,
728
722
  Gt as getLineLength,
729
723
  qt as getOSMLayer,
730
- on as getRealCircleCoordinates,
724
+ rn as getRealCircleCoordinates,
731
725
  Ht as getTianDiTuLayer,
732
- ht as getTianDiTuUrl,
726
+ pt as getTianDiTuUrl,
733
727
  Nt as kmToNauticalMiles,
734
728
  te as mercatorExtentToWgs84,
735
- pt as mercatorToWgs84,
729
+ ht as mercatorToWgs84,
736
730
  jt as nauticalMilesToKm,
737
731
  it as olMapInjectionKey,
738
732
  X as toOlAngle,
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,14 @@
1
1
  import { Map as OLMap } from 'ol';
2
2
  import { MaybeRef, Ref } from 'vue';
3
- import { Stroke } from 'ol/style';
3
+ import { StrokeOptions } from '../../utils';
4
+ import { Graticule } from 'ol/layer';
5
+ export type _GraticuleOptions = ConstructorParameters<typeof Graticule>[0];
6
+ export type GraticuleOptions = _GraticuleOptions & {
7
+ strokeStyleOption?: StrokeOptions;
8
+ };
4
9
  export interface UseGraticuleOptions {
5
10
  olMap: MaybeRef<OLMap | null | undefined>;
6
- strokeStyle?: Stroke;
11
+ graticuleOptions?: GraticuleOptions;
7
12
  defaultShow?: boolean;
8
13
  }
9
14
  export declare function useGraticule(options: UseGraticuleOptions): {
@@ -1,24 +1,18 @@
1
1
  import { Graticule as a } from "ol/layer";
2
- import { Stroke as o } from "ol/style";
3
- import { ref as i, watch as u, toValue as w } from "vue";
4
- function h(e) {
5
- const r = i(e.defaultShow || !1);
2
+ import { Stroke as s } from "ol/style";
3
+ import { ref as p, watch as f, toValue as w } from "vue";
4
+ function d(e) {
5
+ const r = p(e.defaultShow || !1), { strokeStyleOption: o, strokeStyle: i, ...n } = e.graticuleOptions || {}, u = o ? new s(o) : i;
6
6
  let t = new a({
7
- strokeStyle: e.strokeStyle || new o({
8
- color: "#000",
9
- width: 1.5,
10
- lineDash: [4, 4]
11
- }),
12
- showLabels: !0,
13
- wrapX: !1,
14
- zIndex: 1
7
+ ...n,
8
+ strokeStyle: u
15
9
  });
16
- return u(
10
+ return f(
17
11
  r,
18
- (s) => {
19
- if (t.setMap(null), s) {
12
+ (c) => {
13
+ if (t.setMap(null), c) {
20
14
  t = new a({
21
- strokeStyle: new o({
15
+ strokeStyle: new s({
22
16
  color: "#555",
23
17
  width: 1.5,
24
18
  lineDash: [4, 4]
@@ -40,5 +34,5 @@ function h(e) {
40
34
  };
41
35
  }
42
36
  export {
43
- h as useGraticule
37
+ d as useGraticule
44
38
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,14 @@
1
1
  import { Map as OLMap } from 'ol';
2
2
  import { MaybeRef, Ref } from 'vue';
3
- import { Stroke } from 'ol/style';
3
+ import { StrokeOptions } from '../../utils';
4
+ import { Graticule } from 'ol/layer';
5
+ export type _GraticuleOptions = ConstructorParameters<typeof Graticule>[0];
6
+ export type GraticuleOptions = _GraticuleOptions & {
7
+ strokeStyleOption?: StrokeOptions;
8
+ };
4
9
  export interface UseGraticuleOptions {
5
10
  olMap: MaybeRef<OLMap | null | undefined>;
6
- strokeStyle?: Stroke;
11
+ graticuleOptions?: GraticuleOptions;
7
12
  defaultShow?: boolean;
8
13
  }
9
14
  export declare function useGraticule(options: UseGraticuleOptions): {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ol/layer"),s=require("ol/style"),r=require("vue");function i(e){const l=r.ref(e.defaultShow||!1);let t=new u.Graticule({strokeStyle:e.strokeStyle||new s.Stroke({color:"#000",width:1.5,lineDash:[4,4]}),showLabels:!0,wrapX:!1,zIndex:1});return r.watch(l,o=>{if(t.setMap(null),o){t=new u.Graticule({strokeStyle:new s.Stroke({color:"#555",width:1.5,lineDash:[4,4]}),showLabels:!0,wrapX:!1,zIndex:1});const a=r.toValue(e.olMap);a&&t.setMap(a)}},{immediate:!0,deep:!0}),{showGraticule:l}}exports.useGraticule=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ol/layer"),a=require("ol/style"),r=require("vue");function y(e){const l=r.ref(e.defaultShow||!1),{strokeStyleOption:o,strokeStyle:i,...c}=e.graticuleOptions||{},n=o?new a.Stroke(o):i;let t=new u.Graticule({...c,strokeStyle:n});return r.watch(l,w=>{if(t.setMap(null),w){t=new u.Graticule({strokeStyle:new a.Stroke({color:"#555",width:1.5,lineDash:[4,4]}),showLabels:!0,wrapX:!1,zIndex:1});const s=r.toValue(e.olMap);s&&t.setMap(s)}},{immediate:!0,deep:!0}),{showGraticule:l}}exports.useGraticule=y;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@summeruse/ol",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1-beta.0",
5
5
  "description": "",
6
6
  "author": "finalsummer",
7
7
  "license": "ISC",