@summeruse/ol 0.0.1-beta.5 → 0.1.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/index.js +600 -521
  3. package/es/components/index.d.ts +1 -1
  4. package/es/components/n-ol-contextmenu/index.vue.mjs +14 -12
  5. package/es/components/n-ol-contextmenu/props.d.ts +2 -2
  6. package/es/components/n-ol-pointermove/index.vue.mjs +14 -14
  7. package/es/components/ol-map/index.vue.d.ts +1 -1
  8. package/es/components/ol-map/index.vue.mjs +1 -1
  9. package/es/components/ol-map/props.d.ts +2 -2
  10. package/es/components/ol-map/props.mjs +1 -1
  11. package/es/composables/common/index.d.ts +1 -1
  12. package/es/composables/common/index.mjs +2 -2
  13. package/es/composables/index.d.ts +2 -2
  14. package/es/composables/useDrawLineString/index.d.ts +10 -6
  15. package/es/composables/useDrawLineString/index.mjs +73 -69
  16. package/es/composables/useDrawPolygon/index.d.ts +10 -6
  17. package/es/composables/useDrawPolygon/index.mjs +65 -61
  18. package/es/composables/useGraticule/index.d.ts +5 -5
  19. package/es/composables/useGraticule/index.mjs +2 -2
  20. package/es/composables/useSwitchBaseLayer/index.d.ts +2 -2
  21. package/es/composables/useSwitchBaseLayer/index.mjs +12 -12
  22. package/es/index.mjs +64 -64
  23. package/es/utils/calculate/index.d.ts +10 -8
  24. package/es/utils/calculate/index.mjs +23 -8
  25. package/es/utils/distance/index.d.ts +2 -2
  26. package/es/utils/distance/index.mjs +8 -3
  27. package/es/utils/feature/index.d.ts +21 -21
  28. package/es/utils/feature/index.mjs +72 -44
  29. package/es/utils/format/index.d.ts +2 -2
  30. package/es/utils/format/index.mjs +6 -1
  31. package/es/utils/index.d.ts +2 -2
  32. package/es/utils/layer/index.d.ts +14 -14
  33. package/es/utils/layer/index.mjs +47 -40
  34. package/es/utils/projection/index.d.ts +8 -8
  35. package/es/utils/projection/index.mjs +21 -6
  36. package/es/utils/realCircle/index.d.ts +2 -2
  37. package/es/utils/realCircle/index.mjs +2 -2
  38. package/es/utils/style/index.d.ts +4 -4
  39. package/es/utils/style/index.mjs +10 -8
  40. package/lib/components/index.d.ts +1 -1
  41. package/lib/components/n-ol-contextmenu/index.vue.js +1 -1
  42. package/lib/components/n-ol-contextmenu/props.d.ts +2 -2
  43. package/lib/components/n-ol-pointermove/index.vue.js +1 -1
  44. package/lib/components/ol-map/index.vue.d.ts +1 -1
  45. package/lib/components/ol-map/index.vue.js +1 -1
  46. package/lib/components/ol-map/props.d.ts +2 -2
  47. package/lib/components/ol-map/props.js +1 -1
  48. package/lib/composables/common/index.d.ts +1 -1
  49. package/lib/composables/common/index.js +1 -1
  50. package/lib/composables/index.d.ts +2 -2
  51. package/lib/composables/useDrawLineString/index.d.ts +10 -6
  52. package/lib/composables/useDrawLineString/index.js +1 -1
  53. package/lib/composables/useDrawPolygon/index.d.ts +10 -6
  54. package/lib/composables/useDrawPolygon/index.js +1 -1
  55. package/lib/composables/useGraticule/index.d.ts +5 -5
  56. package/lib/composables/useGraticule/index.js +1 -1
  57. package/lib/composables/useSwitchBaseLayer/index.d.ts +2 -2
  58. package/lib/composables/useSwitchBaseLayer/index.js +1 -1
  59. package/lib/index.js +1 -1
  60. package/lib/utils/calculate/index.d.ts +10 -8
  61. package/lib/utils/calculate/index.js +1 -1
  62. package/lib/utils/distance/index.d.ts +2 -2
  63. package/lib/utils/distance/index.js +1 -1
  64. package/lib/utils/feature/index.d.ts +21 -21
  65. package/lib/utils/feature/index.js +1 -1
  66. package/lib/utils/format/index.d.ts +2 -2
  67. package/lib/utils/format/index.js +1 -1
  68. package/lib/utils/index.d.ts +2 -2
  69. package/lib/utils/layer/index.d.ts +14 -14
  70. package/lib/utils/layer/index.js +1 -1
  71. package/lib/utils/projection/index.d.ts +8 -8
  72. package/lib/utils/projection/index.js +1 -1
  73. package/lib/utils/realCircle/index.d.ts +2 -2
  74. package/lib/utils/realCircle/index.js +1 -1
  75. package/lib/utils/style/index.d.ts +4 -4
  76. package/lib/utils/style/index.js +1 -1
  77. package/package.json +20 -19
  78. package/es/components/common/render-v-node.vue.d.ts +0 -17
  79. package/es/components/common/render-v-node.vue.mjs +0 -22
  80. package/es/components/common/render-v-node.vue2.mjs +0 -4
  81. package/lib/components/common/render-v-node.vue.d.ts +0 -17
  82. package/lib/components/common/render-v-node.vue.js +0 -1
  83. package/lib/components/common/render-v-node.vue2.js +0 -1
@@ -1,58 +1,65 @@
1
1
  import { Tile as c } from "ol/layer";
2
- import { XYZ as y, BingMaps as m, OSM as u } from "ol/source";
3
- import { WebMercatorProjection as i, WGS84Projection as T } from "../../constants/projection.mjs";
4
- import p from "ol/source/Vector";
5
- import E from "ol/layer/Vector";
6
- import { createStyle as L } from "../style/index.mjs";
7
- const S = (e) => {
8
- const { type: r = "img", projection: o = i, key: t } = e, n = e.url || "https://t{0-4}.tianditu.gov.cn", s = "&tk=" + t + // cSpell:disable-next-line
9
- "&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}", l = o === T ? "c" : o === i ? "w" : "c";
10
- return n + "/" + r + "_" + l + "/wmts?LAYER=" + r + s;
11
- }, R = (e) => {
12
- const { zIndex: r, projection: o, className: t } = e;
2
+ import l from "ol/layer/Vector";
3
+ import { XYZ as u, BingMaps as y, OSM as m } from "ol/source";
4
+ import T from "ol/source/Vector";
5
+ import { WebMercatorProjection as i, WGS84Projection as p } from "../../constants/projection.mjs";
6
+ import { createStyle as f } from "../style/index.mjs";
7
+ function E(e) {
8
+ const { type: r = "img", projection: o = i, key: n } = e, t = e.url || "https://t{0-4}.tianditu.gov.cn", s = `&tk=${n}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
9
+ return `${t}/${r}_${o === p ? "c" : o === i ? "w" : "c"}/wmts?LAYER=${r}${s}`;
10
+ }
11
+ function R(e) {
12
+ const { zIndex: r, projection: o, className: n } = e;
13
13
  return new c({
14
- className: t,
15
- source: new y({
16
- url: S(e),
14
+ className: n,
15
+ source: new u({
16
+ url: E(e),
17
17
  projection: o,
18
18
  crossOrigin: "Anonymous"
19
19
  }),
20
20
  zIndex: r
21
21
  });
22
- }, x = ({
22
+ }
23
+ function j({
23
24
  name: e,
24
25
  zIndex: r,
25
26
  key: o,
26
- className: t
27
- }) => new c({
28
- className: t,
29
- source: new m({
30
- key: o,
31
- imagerySet: e,
32
- placeholderTiles: !1
33
- }),
34
- zIndex: r
35
- }), A = (e) => new c({
36
- className: e == null ? void 0 : e.className,
37
- source: new u({
38
- crossOrigin: "Anonymous"
39
- }),
40
- zIndex: e == null ? void 0 : e.zIndex
41
- }), a = (e) => {
42
- const { styleOptions: r, ...o } = e || {}, t = r ? L(r) : void 0, n = new p(), s = new E({
43
- source: n,
27
+ className: n
28
+ }) {
29
+ return new c({
30
+ className: n,
31
+ source: new y({
32
+ key: o,
33
+ imagerySet: e,
34
+ placeholderTiles: !1
35
+ }),
36
+ zIndex: r
37
+ });
38
+ }
39
+ function x(e) {
40
+ return new c({
41
+ className: e == null ? void 0 : e.className,
42
+ source: new m({
43
+ crossOrigin: "Anonymous"
44
+ }),
45
+ zIndex: e == null ? void 0 : e.zIndex
46
+ });
47
+ }
48
+ function A(e) {
49
+ const { styleOptions: r, ...o } = e || {}, n = r ? f(r) : void 0, t = new T(), s = new l({
50
+ source: t,
44
51
  ...o,
45
- style: t || o.style
52
+ style: n || o.style
46
53
  });
47
54
  return {
48
- source: n,
55
+ source: t,
49
56
  layer: s
50
57
  };
51
- };
58
+ }
52
59
  export {
53
- a as createVectorLayer,
54
- x as getBingLayer,
55
- A as getOSMLayer,
60
+ A as createVectorLayer,
61
+ j as getBingLayer,
62
+ x as getOSMLayer,
56
63
  R as getTianDiTuLayer,
57
- S as getTianDiTuUrl
64
+ E as getTianDiTuUrl
58
65
  };
@@ -1,18 +1,18 @@
1
1
  import { Coordinate } from 'ol/coordinate';
2
2
  import { Extent } from 'ol/extent';
3
3
  /** WGS84坐标转墨卡托 */
4
- export declare const wgs84ToMercator: (coordinate: Coordinate) => Coordinate;
4
+ export declare function wgs84ToMercator(coordinate: Coordinate): Coordinate;
5
5
  /** WGS84坐标转墨卡托 */
6
- export declare const EPSG_4326ToEPSG_3857: (coordinate: Coordinate) => Coordinate;
6
+ export declare const EPSG_4326ToEPSG_3857: typeof wgs84ToMercator;
7
7
  /** 墨卡托坐标转WGS84 */
8
- export declare const mercatorToWgs84: (coordinate: Coordinate) => Coordinate;
8
+ export declare function mercatorToWgs84(coordinate: Coordinate): Coordinate;
9
9
  /** 墨卡托坐标转WGS84 */
10
- export declare const EPSG_3857ToEPSG_4326: (coordinate: Coordinate) => Coordinate;
10
+ export declare const EPSG_3857ToEPSG_4326: typeof mercatorToWgs84;
11
11
  /** WGS84范围转墨卡托 */
12
- export declare const wgs84ExtentToMercator: (extent: Extent) => Extent;
12
+ export declare function wgs84ExtentToMercator(extent: Extent): Extent;
13
13
  /** WGS84范围转墨卡托 */
14
- export declare const EPSG_4326ExtentToEPSG_3857: (extent: Extent) => Extent;
14
+ export declare const EPSG_4326ExtentToEPSG_3857: typeof wgs84ExtentToMercator;
15
15
  /** 墨卡托范围转WGS84 */
16
- export declare const mercatorExtentToWgs84: (extent: Extent) => Extent;
16
+ export declare function mercatorExtentToWgs84(extent: Extent): Extent;
17
17
  /** 墨卡托范围转WGS84 */
18
- export declare const EPSG_3857ExtentToEPSG_4326: (extent: Extent) => Extent;
18
+ export declare const EPSG_3857ExtentToEPSG_4326: typeof mercatorExtentToWgs84;
@@ -1,13 +1,28 @@
1
1
  import { transform as n, transformExtent as E } from "ol/proj";
2
2
  import { EPSG_4326 as o, EPSG_3857 as r } from "../../constants/projection.mjs";
3
- const e = (t) => n(t, o, r), _ = e, s = (t) => n(t, r, o), m = s, c = (t) => E(t, o, r), T = c, G = (t) => E(t, r, o), a = G;
3
+ function e(t) {
4
+ return n(t, o, r);
5
+ }
6
+ const _ = e;
7
+ function c(t) {
8
+ return n(t, r, o);
9
+ }
10
+ const f = c;
11
+ function s(t) {
12
+ return E(t, o, r);
13
+ }
14
+ const m = s;
15
+ function G(t) {
16
+ return E(t, r, o);
17
+ }
18
+ const u = G;
4
19
  export {
5
- a as EPSG_3857ExtentToEPSG_4326,
6
- m as EPSG_3857ToEPSG_4326,
7
- T as EPSG_4326ExtentToEPSG_3857,
20
+ u as EPSG_3857ExtentToEPSG_4326,
21
+ f as EPSG_3857ToEPSG_4326,
22
+ m as EPSG_4326ExtentToEPSG_3857,
8
23
  _ as EPSG_4326ToEPSG_3857,
9
24
  G as mercatorExtentToWgs84,
10
- s as mercatorToWgs84,
11
- c as wgs84ExtentToMercator,
25
+ c as mercatorToWgs84,
26
+ s as wgs84ExtentToMercator,
12
27
  e as wgs84ToMercator
13
28
  };
@@ -3,7 +3,7 @@ import { Coordinate } from 'ol/coordinate';
3
3
  * 获取一个地理圆形的坐标点
4
4
  * @param coordinate 中心坐标 EPSG:4326 WGS84
5
5
  * @param radius 单位:米
6
- * @param [sides=60] 边数
6
+ * @param [sides] 边数
7
7
  * @returns 伪圆形坐标 EPSG:4326 WGS84
8
8
  */
9
- export declare const getRealCircleCoordinates: (coordinate: Coordinate, radius: number, sides?: number) => Coordinate[][];
9
+ export declare function getRealCircleCoordinates(coordinate: Coordinate, radius: number, sides?: number): Coordinate[][];
@@ -1,10 +1,10 @@
1
1
  import { getDestinationPoint as s } from "../calculate/index.mjs";
2
- const c = (e, n, i = 60) => {
2
+ function c(e, n, i = 60) {
3
3
  const o = [], r = 360 / i;
4
4
  for (let t = -180; t < 180; t = t + r)
5
5
  o.push(s(e, n, t));
6
6
  return [o];
7
- };
7
+ }
8
8
  export {
9
9
  c as getRealCircleCoordinates
10
10
  };
@@ -1,4 +1,4 @@
1
- import { Fill, Icon, Stroke, Style, Circle, Text } from 'ol/style';
1
+ import { Circle, Fill, Icon, Stroke, Style, Text } from 'ol/style';
2
2
  export type FillOptions = ConstructorParameters<typeof Fill>[0];
3
3
  export type StrokeOptions = ConstructorParameters<typeof Stroke>[0];
4
4
  export type IconOptions = ConstructorParameters<typeof Icon>[0];
@@ -22,6 +22,6 @@ export type StyleOptions = _StyleOptions & {
22
22
  circleOptions?: CircleOptions;
23
23
  textOptions?: TextOptions;
24
24
  };
25
- export declare const createCircleStyle: (options: CircleOptions) => Circle;
26
- export declare const createTextStyle: (options: TextOptions) => Text;
27
- export declare const createStyle: (options: StyleOptions) => Style;
25
+ export declare function createCircleStyle(options: CircleOptions): Circle;
26
+ export declare function createTextStyle(options: TextOptions): Text;
27
+ export declare function createStyle(options: StyleOptions): Style;
@@ -1,30 +1,32 @@
1
- import { Circle as O, Stroke as s, Fill as c, Text as a, Icon as f, Style as u } from "ol/style";
2
- const S = (n) => {
1
+ import { Circle as O, Stroke as s, Fill as c, Text as f, Icon as u, Style as a } from "ol/style";
2
+ function S(n) {
3
3
  const { fillOptions: o, strokeOptions: t, ...e } = n;
4
4
  return new O({
5
5
  ...e,
6
6
  fill: o ? new c(o) : void 0,
7
7
  stroke: t ? new s(t) : void 0
8
8
  });
9
- }, g = (n) => {
9
+ }
10
+ function g(n) {
10
11
  const { fillOptions: o, strokeOptions: t, backgroundFillOptions: e, backgroundStrokeOptions: i, ...r } = n;
11
- return new a({
12
+ return new f({
12
13
  ...r,
13
14
  fill: o ? new c(o) : void 0,
14
15
  stroke: t ? new s(t) : void 0,
15
16
  backgroundFill: e ? new c(e) : void 0,
16
17
  backgroundStroke: i ? new s(i) : void 0
17
18
  });
18
- }, b = (n) => {
19
- const { fillOptions: o, strokeOptions: t, iconOptions: e, circleOptions: i, textOptions: r, ...l } = n, d = o ? new c(o) : void 0, k = t ? new s(t) : void 0, p = e ? new f(e) : void 0, w = i ? S(i) : void 0, v = r ? g(r) : void 0;
20
- return new u({
19
+ }
20
+ function b(n) {
21
+ const { fillOptions: o, strokeOptions: t, iconOptions: e, circleOptions: i, textOptions: r, ...l } = n, d = o ? new c(o) : void 0, k = t ? new s(t) : void 0, p = e ? new u(e) : void 0, w = i ? S(i) : void 0, v = r ? g(r) : void 0;
22
+ return new a({
21
23
  ...l,
22
24
  fill: d,
23
25
  stroke: k,
24
26
  image: p || w,
25
27
  text: v
26
28
  });
27
- };
29
+ }
28
30
  export {
29
31
  S as createCircleStyle,
30
32
  b as createStyle,
@@ -1,3 +1,3 @@
1
1
  export * from './n-ol-contextmenu';
2
- export * from './ol-map';
3
2
  export * from './n-ol-pointermove';
3
+ export * from './ol-map';
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),d=require("naive-ui"),f=t.defineComponent({__name:"index",props:{olMap:{},createOptions:{type:Function}},setup(a){const c=a,{olMap:i}=c,o=t.ref({visible:!1,x:0,y:0}),r=()=>{o.value.visible=!1},l=t.ref();t.onMounted(()=>{const s=i.getViewport();s&&(s.oncontextmenu=e=>{e.preventDefault();const n=i.getEventPixel(e),p=i.getEventCoordinate(e),v=i.getFeaturesAtPixel(n);l.value=c.createOptions({event:e,pixel:n,coordinate:p,features:v}),o.value={visible:!0,x:e.clientX,y:e.clientY}})});const u=(s,e)=>{const{onClick:n}=e;n&&n(),o.value.visible=!1};return(s,e)=>(t.openBlock(),t.createBlock(t.unref(d.NDropdown),{placement:"bottom-start",trigger:"manual",show:l.value&&l.value.length>0&&o.value.visible,x:o.value.x,y:o.value.y,options:l.value,"on-clickoutside":r,onSelect:u},null,8,["show","x","y","options"]))}});exports.default=f;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),d=require("naive-ui"),f=t.defineComponent({__name:"index",props:{olMap:{},createOptions:{type:Function}},setup(u){const c=u,{olMap:i}=c,o=t.ref({visible:!1,x:0,y:0});function a(){o.value.visible=!1}const l=t.ref();t.onMounted(()=>{const s=i.getViewport();s&&(s.oncontextmenu=e=>{e.preventDefault();const n=i.getEventPixel(e),p=i.getEventCoordinate(e),v=i.getFeaturesAtPixel(n);l.value=c.createOptions({event:e,pixel:n,coordinate:p,features:v}),o.value={visible:!0,x:e.clientX,y:e.clientY}})});function r(s,e){const{onClick:n}=e;n&&n(),o.value.visible=!1}return(s,e)=>(t.openBlock(),t.createBlock(t.unref(d.NDropdown),{placement:"bottom-start",trigger:"manual",show:l.value&&l.value.length>0&&o.value.visible,x:o.value.x,y:o.value.y,options:l.value,"on-clickoutside":a,onSelect:r},null,8,["show","x","y","options"]))}});exports.default=f;
@@ -1,8 +1,8 @@
1
- import { Map as OLMap } from 'ol';
2
1
  import { DropdownMixedOption } from 'naive-ui/es/dropdown/src/interface';
3
- import { Pixel } from 'ol/pixel';
2
+ import { Map as OLMap } from 'ol';
4
3
  import { Coordinate } from 'ol/coordinate';
5
4
  import { FeatureLike } from 'ol/Feature';
5
+ import { Pixel } from 'ol/pixel';
6
6
  export interface NOlContextmenuOptions {
7
7
  event: MouseEvent;
8
8
  pixel: Pixel;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("naive-ui"),w=require("../common/render-v-node.vue.js"),m=e.defineComponent({__name:"index",props:{olMap:{},createOptions:{type:Function}},setup(c){const l=c,o=e.ref({visible:!1,x:0,y:0}),r=e.shallowRef(),s=e.ref("bottom-start"),i=e.ref(!1),u=e.ref(!1);return e.onMounted(()=>{var n;(n=l.olMap)==null||n.on("pointermove",t=>{const v=l.olMap.getFeaturesAtPixel(t.pixel),{clientX:p,clientY:d}=t.originalEvent;o.value.visible=!1;const a=l.createOptions({pixel:t.pixel,coordinate:t.coordinate,features:v});a&&(r.value=a.content,s.value=a.placement||"bottom-start",u.value=a.showArrow||!1,i.value=a.raw||!1,o.value.visible=!0,o.value.x=p,o.value.y=d)})}),(n,t)=>(e.openBlock(),e.createBlock(e.unref(f.NPopover),{"show-arrow":u.value,raw:i.value,placement:s.value,show:o.value.visible,x:o.value.x,y:o.value.y,trigger:"manual",class:"n-ol-pointermove","theme-overrides":{boxShadow:"none"}},{default:e.withCtx(()=>[e.createVNode(w.default,{"dynamic-v-node":r.value},null,8,["dynamic-v-node"])]),_:1},8,["show-arrow","raw","placement","show","x","y"]))}});exports.default=m;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("@summeruse/common"),m=require("naive-ui"),w=e.defineComponent({__name:"index",props:{olMap:{},createOptions:{type:Function}},setup(u){const n=u,o=e.ref({visible:!1,x:0,y:0}),r=e.shallowRef(),s=e.ref("bottom-start"),i=e.ref(!1),c=e.ref(!1);return e.onMounted(()=>{var l;(l=n.olMap)==null||l.on("pointermove",t=>{const v=n.olMap.getFeaturesAtPixel(t.pixel),{clientX:p,clientY:f}=t.originalEvent;o.value.visible=!1;const a=n.createOptions({pixel:t.pixel,coordinate:t.coordinate,features:v});a&&(r.value=a.content,s.value=a.placement||"bottom-start",c.value=a.showArrow||!1,i.value=a.raw||!1,o.value.visible=!0,o.value.x=p,o.value.y=f)})}),(l,t)=>(e.openBlock(),e.createBlock(e.unref(m.NPopover),{"show-arrow":c.value,raw:i.value,placement:s.value,show:o.value.visible,x:o.value.x,y:o.value.y,trigger:"manual",class:"n-ol-pointermove","theme-overrides":{boxShadow:"none"}},{default:e.withCtx(()=>[e.createVNode(e.unref(d.RenderVNode),{"dynamic-v-node":r.value},null,8,["dynamic-v-node"])]),_:1},8,["show-arrow","raw","placement","show","x","y"]))}});exports.default=w;
@@ -1,5 +1,5 @@
1
- import { Map as OLMap } from 'ol';
2
1
  import { OlMapProps } from './props';
2
+ import { Map as OLMap } from 'ol';
3
3
  declare function __VLS_template(): {
4
4
  attrs: Partial<{}>;
5
5
  slots: {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),h=require("ol"),S=require("./props.js"),i=require("ol/control"),a=require("ol/interaction"),P=o.defineComponent({__name:"index",props:{olMap:{default:()=>new h.Map},center:{default:()=>[0,0]},zoom:{default:2},minZoom:{default:2},maxZoom:{default:18},constrainResolution:{type:Boolean,default:!0},projection:{},extent:{},showZoom:{type:Boolean,default:!1},showAttribution:{type:Boolean,default:!1},showRotate:{type:Boolean,default:!1},showFullScreen:{type:Boolean,default:!1},showOverview:{type:Boolean,default:!1},showScale:{type:Boolean,default:!1},dragPan:{type:Boolean,default:!0},mouseWheelZoom:{type:Boolean,default:!0},doubleClickZoom:{type:Boolean,default:!1},pinchRotate:{type:Boolean},pinchZoom:{type:Boolean},altShiftDragRotate:{type:Boolean}},setup(Z,{expose:v}){const n=Z,s=o.ref(),t=n.olMap,c=new h.View({projection:n.projection,extent:n.extent});t.setView(c),o.watch(()=>n.zoom,e=>{c.setZoom(e)},{immediate:!0}),o.watch(()=>n.center,e=>{c.setCenter(e)},{immediate:!0}),o.watch(()=>n.constrainResolution,e=>{c.setConstrainResolution(e)},{immediate:!0}),o.watch(()=>n.minZoom,e=>{e&&c.setMinZoom(e)},{immediate:!0}),o.watch(()=>n.maxZoom,e=>{e&&c.setMaxZoom(e)},{immediate:!0}),o.watch(s,e=>{e&&t.setTarget(e)}),v({olMap:t}),o.provide(S.olMapInjectionKey,t);const l=t.getControls().getArray(),y=l.find(e=>e instanceof i.Zoom)||new i.Zoom,M=l.find(e=>e instanceof i.Attribution)||new i.Attribution,R=l.find(e=>e instanceof i.Rotate)||new i.Rotate,b=l.find(e=>e instanceof i.FullScreen)||new i.FullScreen,g=l.find(e=>e instanceof i.OverviewMap)||new i.OverviewMap,I=l.find(e=>e instanceof i.ScaleLine)||new i.ScaleLine;o.watch(()=>n.showZoom,e=>{y.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showAttribution,e=>{M.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showRotate,e=>{R.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showFullScreen,e=>{b.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showOverview,e=>{g.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showScale,e=>{I.setMap(e?t:null)},{immediate:!0});const r=t.getInteractions().getArray(),m=r.find(e=>e instanceof a.DragPan)||new a.DragPan,u=r.find(e=>e instanceof a.MouseWheelZoom)||new a.MouseWheelZoom,d=r.find(e=>e instanceof a.DoubleClickZoom)||new a.DoubleClickZoom,f=r.find(e=>e instanceof a.PinchRotate)||new a.PinchRotate,w=r.find(e=>e instanceof a.PinchZoom)||new a.PinchZoom,p=r.find(e=>e instanceof a.DragRotate)||new a.DragRotate,B=r.find(e=>e instanceof a.KeyboardPan)||new a.KeyboardPan,C=r.find(e=>e instanceof a.KeyboardZoom)||new a.KeyboardZoom;return t.removeInteraction(m),t.addInteraction(m),t.removeInteraction(u),t.addInteraction(u),t.removeInteraction(d),t.addInteraction(d),t.removeInteraction(f),t.addInteraction(f),t.removeInteraction(w),t.addInteraction(w),t.removeInteraction(p),t.addInteraction(p),t.removeInteraction(B),t.removeInteraction(C),o.watch(()=>n.dragPan,e=>{m.setActive(e)},{immediate:!0}),o.watch(()=>n.mouseWheelZoom,e=>{u.setActive(e)},{immediate:!0}),o.watch(()=>n.doubleClickZoom,e=>{d.setActive(e)},{immediate:!0}),o.watch(()=>n.pinchRotate,e=>{f.setActive(e)},{immediate:!0}),o.watch(()=>n.pinchZoom,e=>{w.setActive(e)},{immediate:!0}),o.watch(()=>n.altShiftDragRotate,e=>{p.setActive(e)},{immediate:!0}),(e,A)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"mapRef",ref:s},[o.renderSlot(e.$slots,"default",{olMap:o.unref(t),mapRef:s.value})],512))}});exports.default=P;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),h=require("ol"),i=require("ol/control"),a=require("ol/interaction"),S=require("./props.js"),P=o.defineComponent({__name:"index",props:{olMap:{default:()=>new h.Map},center:{default:()=>[0,0]},zoom:{default:2},minZoom:{default:2},maxZoom:{default:18},constrainResolution:{type:Boolean,default:!0},projection:{},extent:{},showZoom:{type:Boolean,default:!1},showAttribution:{type:Boolean,default:!1},showRotate:{type:Boolean,default:!1},showFullScreen:{type:Boolean,default:!1},showOverview:{type:Boolean,default:!1},showScale:{type:Boolean,default:!1},dragPan:{type:Boolean,default:!0},mouseWheelZoom:{type:Boolean,default:!0},doubleClickZoom:{type:Boolean,default:!1},pinchRotate:{type:Boolean},pinchZoom:{type:Boolean},altShiftDragRotate:{type:Boolean}},setup(Z,{expose:v}){const n=Z,s=o.ref(),t=n.olMap,c=new h.View({projection:n.projection,extent:n.extent});t.setView(c),o.watch(()=>n.zoom,e=>{c.setZoom(e)},{immediate:!0}),o.watch(()=>n.center,e=>{c.setCenter(e)},{immediate:!0}),o.watch(()=>n.constrainResolution,e=>{c.setConstrainResolution(e)},{immediate:!0}),o.watch(()=>n.minZoom,e=>{e&&c.setMinZoom(e)},{immediate:!0}),o.watch(()=>n.maxZoom,e=>{e&&c.setMaxZoom(e)},{immediate:!0}),o.watch(s,e=>{e&&t.setTarget(e)}),v({olMap:t}),o.provide(S.olMapInjectionKey,t);const l=t.getControls().getArray(),y=l.find(e=>e instanceof i.Zoom)||new i.Zoom,M=l.find(e=>e instanceof i.Attribution)||new i.Attribution,R=l.find(e=>e instanceof i.Rotate)||new i.Rotate,b=l.find(e=>e instanceof i.FullScreen)||new i.FullScreen,g=l.find(e=>e instanceof i.OverviewMap)||new i.OverviewMap,I=l.find(e=>e instanceof i.ScaleLine)||new i.ScaleLine;o.watch(()=>n.showZoom,e=>{y.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showAttribution,e=>{M.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showRotate,e=>{R.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showFullScreen,e=>{b.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showOverview,e=>{g.setMap(e?t:null)},{immediate:!0}),o.watch(()=>n.showScale,e=>{I.setMap(e?t:null)},{immediate:!0});const r=t.getInteractions().getArray(),m=r.find(e=>e instanceof a.DragPan)||new a.DragPan,u=r.find(e=>e instanceof a.MouseWheelZoom)||new a.MouseWheelZoom,d=r.find(e=>e instanceof a.DoubleClickZoom)||new a.DoubleClickZoom,f=r.find(e=>e instanceof a.PinchRotate)||new a.PinchRotate,w=r.find(e=>e instanceof a.PinchZoom)||new a.PinchZoom,p=r.find(e=>e instanceof a.DragRotate)||new a.DragRotate,B=r.find(e=>e instanceof a.KeyboardPan)||new a.KeyboardPan,C=r.find(e=>e instanceof a.KeyboardZoom)||new a.KeyboardZoom;return t.removeInteraction(m),t.addInteraction(m),t.removeInteraction(u),t.addInteraction(u),t.removeInteraction(d),t.addInteraction(d),t.removeInteraction(f),t.addInteraction(f),t.removeInteraction(w),t.addInteraction(w),t.removeInteraction(p),t.addInteraction(p),t.removeInteraction(B),t.removeInteraction(C),o.watch(()=>n.dragPan,e=>{m.setActive(e)},{immediate:!0}),o.watch(()=>n.mouseWheelZoom,e=>{u.setActive(e)},{immediate:!0}),o.watch(()=>n.doubleClickZoom,e=>{d.setActive(e)},{immediate:!0}),o.watch(()=>n.pinchRotate,e=>{f.setActive(e)},{immediate:!0}),o.watch(()=>n.pinchZoom,e=>{w.setActive(e)},{immediate:!0}),o.watch(()=>n.altShiftDragRotate,e=>{p.setActive(e)},{immediate:!0}),(e,A)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"mapRef",ref:s},[o.renderSlot(e.$slots,"default",{olMap:o.unref(t),mapRef:s.value})],512))}});exports.default=P;
@@ -3,7 +3,7 @@ import { Coordinate } from 'ol/coordinate';
3
3
  import { Extent } from 'ol/extent';
4
4
  import { InjectionKey } from 'vue';
5
5
  import { ProjectionLike } from '../../constants/projection';
6
- export type OlMapProps = {
6
+ export interface OlMapProps {
7
7
  olMap?: OLMap;
8
8
  center?: Coordinate;
9
9
  zoom?: number;
@@ -24,5 +24,5 @@ export type OlMapProps = {
24
24
  pinchRotate?: boolean;
25
25
  pinchZoom?: boolean;
26
26
  altShiftDragRotate?: boolean;
27
- };
27
+ }
28
28
  export declare const olMapInjectionKey: InjectionKey<OLMap>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Symbol();exports.olMapInjectionKey=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Symbol("olMapInjectionKey");exports.olMapInjectionKey=e;
@@ -1 +1 @@
1
- export declare const createToolTipElement: (text: string) => HTMLDivElement;
1
+ export declare function createToolTipElement(text: string): HTMLDivElement;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=t=>{const e=document.createElement("div");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};exports.createToolTipElement=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(t){const e=document.createElement("div");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}exports.createToolTipElement=o;
@@ -1,4 +1,4 @@
1
- export * from './useGraticule';
2
- export * from './useSwitchBaseLayer';
3
1
  export * from './useDrawLineString';
4
2
  export * from './useDrawPolygon';
3
+ export * from './useGraticule';
4
+ export * from './useSwitchBaseLayer';
@@ -1,20 +1,24 @@
1
- import { OLMap } from '../../types';
1
+ import { Coordinate } from 'ol/coordinate';
2
2
  import { Style } from 'ol/style';
3
+ import { VNode } from 'vue';
4
+ import { OLMap } from '../../types';
5
+ import { StyleOptions } from '../../utils';
3
6
  import { Feature } from 'ol';
4
7
  import { LineString } from 'ol/geom';
5
- import { VNode } from 'vue';
6
- import { Coordinate } from 'ol/coordinate';
7
- export type DrawLineStringOptions = {
8
+ export interface DrawLineStringOptions {
8
9
  defaultCoordinates?: Coordinate[][];
9
10
  deletePointLabel?: VNode;
10
11
  deleteFeatureLabel?: VNode;
11
12
  style?: Style;
13
+ styleOptions?: StyleOptions;
12
14
  drawStyle?: Style;
15
+ drawStyleOptions?: StyleOptions;
13
16
  modifyStyle?: Style;
17
+ modifyStyleOptions?: StyleOptions;
14
18
  zIndex?: number;
15
19
  size?: number;
16
- };
17
- export declare const useDrawLineString: (olMap: OLMap, options: DrawLineStringOptions) => {
20
+ }
21
+ export declare function useDrawLineString(olMap: OLMap, options: DrawLineStringOptions): {
18
22
  inDraw: import('vue').Ref<boolean, boolean>;
19
23
  start: () => void;
20
24
  stop: () => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("ol/source/Vector"),k=require("ol/layer/Vector"),x=require("ol/interaction"),v=require("ol"),z=require("ol/geom"),a=require("vue"),V=require("../../utils/calculate/index.js"),O=require("../../utils/projection/index.js"),T=require("../common/index.js"),$=(r,e)=>{const f=a.ref(!0),d=a.ref([]),b=a.computed(()=>d.value.map(c=>c.getGeometry().getCoordinates())),t=new P,m=new k({source:t,style:e==null?void 0:e.style,zIndex:e==null?void 0:e.zIndex});r.addLayer(m);const n=new x.Draw({source:t,style:(e==null?void 0:e.drawStyle)||(e==null?void 0:e.style),type:"LineString"});n.setActive(!1);const o=new x.Modify({source:t,style:(e==null?void 0:e.modifyStyle)||(e==null?void 0:e.style)}),u=new Set;r.addInteraction(n),a.onMounted(()=>{r.addInteraction(o)}),t.on("addfeature",()=>{e.size&&t.getFeatures().length>=e.size&&n.setActive(!1)}),t.on("removefeature",()=>{e.size&&t.getFeatures().length<e.size&&n.setActive(!0)});const w=()=>{u.forEach(c=>{r.removeOverlay(c)}),u.clear()};t.on("change",()=>{w(),t.getFeatures().forEach(c=>{const l=c.getGeometry(),g=V.getExtentCenter(O.mercatorExtentToWgs84(l.getExtent()));let s=document.createElement("div");e.deleteFeatureLabel?a.render(e.deleteFeatureLabel,s):s=T.createToolTipElement("删除线"),s.addEventListener("click",()=>{t.removeFeature(c)});const F=new v.Overlay({position:O.wgs84ToMercator(g),positioning:"center-center",element:s});u.add(F),r.addOverlay(F);const y=l.getCoordinates();y.length<3||y.forEach((C,D)=>{let i=document.createElement("div");e.deletePointLabel?a.render(e.deletePointLabel,i):i=T.createToolTipElement("删除点"),i.addEventListener("click",()=>{c.setGeometry(new z.LineString(y.filter((j,G)=>G!==D)))});const q=new v.Overlay({position:C,positioning:"top-center",offset:[0,-30],element:i});u.add(q),r.addOverlay(q)})})}),n.on("change:active",()=>{f.value=n.getActive()}),t.on("change",()=>{d.value=t.getFeatures()});const L=()=>{w(),r.removeLayer(m),r.removeInteraction(n),r.removeInteraction(o)},A=()=>{e.size&&d.value.length>=e.size||n.setActive(!0)},E=()=>{n.setActive(!1)},h=c=>{t.clear(),c.forEach(l=>{if(l.length<2)return;const g=new v.Feature({geometry:new z.LineString(l)});t.addFeature(g)})},S=()=>{h(e.defaultCoordinates||[])};S();const I=()=>{t.clear(),E()};return a.onUnmounted(()=>{L()}),{inDraw:f,start:A,stop:E,clear:I,setFeatures:h,reset:S,features:d,coordinates:b,destroy:L}};exports.useDrawLineString=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("ol"),z=require("ol/geom"),T=require("ol/interaction"),j=require("ol/layer/Vector"),U=require("ol/source/Vector"),a=require("vue"),W=require("../../utils/calculate/index.js"),v=require("../../utils/style/index.js");require("ol/layer");require("ol/source");const b=require("../../utils/projection/index.js"),A=require("../common/index.js");function _(r,e){const m=a.ref(!0),d=a.ref([]),I=a.computed(()=>d.value.map(c=>c.getGeometry().getCoordinates())),t=new U,y=e.styleOptions?v.createStyle(e.styleOptions):e==null?void 0:e.style,S=new j({source:t,style:y,zIndex:e==null?void 0:e.zIndex});r.addLayer(S);const C=e.drawStyleOptions?v.createStyle(e.drawStyleOptions):e==null?void 0:e.drawStyle,n=new T.Draw({source:t,style:C||y,type:"LineString"});n.setActive(!1);const D=e.modifyStyleOptions?v.createStyle(e.modifyStyleOptions):e==null?void 0:e.modifyStyle,w=new T.Modify({source:t,style:D||y}),i=new Set;r.addInteraction(n),a.onMounted(()=>{r.addInteraction(w)}),t.on("addfeature",()=>{e.size&&t.getFeatures().length>=e.size&&n.setActive(!1)}),t.on("removefeature",()=>{e.size&&t.getFeatures().length<e.size&&n.setActive(!0)});const L=()=>{i.forEach(c=>{r.removeOverlay(c)}),i.clear()};t.on("change",()=>{L(),t.getFeatures().forEach(c=>{const l=c.getGeometry(),o=W.getExtentCenter(b.mercatorExtentToWgs84(l.getExtent()));let s=document.createElement("div");e.deleteFeatureLabel?a.render(e.deleteFeatureLabel,s):s=A.createToolTipElement("删除线"),s.addEventListener("click",()=>{t.removeFeature(c)});const F=new f.Overlay({position:b.wgs84ToMercator(o),positioning:"center-center",element:s});i.add(F),r.addOverlay(F);const g=l.getCoordinates();g.length<3||g.forEach(($,k)=>{let u=document.createElement("div");e.deletePointLabel?a.render(e.deletePointLabel,u):u=A.createToolTipElement("删除点"),u.addEventListener("click",()=>{c.setGeometry(new z.LineString(g.filter((B,V)=>V!==k)))});const x=new f.Overlay({position:$,positioning:"top-center",offset:[0,-30],element:u});i.add(x),r.addOverlay(x)})})}),n.on("change:active",()=>{m.value=n.getActive()}),t.on("change",()=>{d.value=t.getFeatures()});const E=()=>{L(),r.removeLayer(S),r.removeInteraction(n),r.removeInteraction(w)},G=()=>{e.size&&d.value.length>=e.size||n.setActive(!0)},O=()=>{n.setActive(!1)},h=c=>{t.clear(),c.forEach(l=>{if(l.length<2)return;const o=new f.Feature({geometry:new z.LineString(l)});t.addFeature(o)})},q=()=>{h(e.defaultCoordinates||[])};q();const P=()=>{t.clear(),O()};return a.onUnmounted(()=>{E()}),{inDraw:m,start:G,stop:O,clear:P,setFeatures:h,reset:q,features:d,coordinates:I,destroy:E}}exports.useDrawLineString=_;
@@ -1,20 +1,24 @@
1
- import { OLMap } from '../../types';
1
+ import { Coordinate } from 'ol/coordinate';
2
2
  import { Style } from 'ol/style';
3
+ import { VNode } from 'vue';
4
+ import { OLMap } from '../../types';
5
+ import { StyleOptions } from '../../utils';
3
6
  import { Feature } from 'ol';
4
7
  import { Polygon } from 'ol/geom';
5
- import { VNode } from 'vue';
6
- import { Coordinate } from 'ol/coordinate';
7
- export type DrawPolygonOptions = {
8
+ export interface DrawPolygonOptions {
8
9
  defaultCoordinates?: Coordinate[][][];
9
10
  deletePointLabel?: VNode;
10
11
  deleteFeatureLabel?: VNode;
11
12
  style?: Style;
13
+ styleOptions?: StyleOptions;
14
+ drawStyleOptions?: StyleOptions;
15
+ modifyStyleOptions?: StyleOptions;
12
16
  drawStyle?: Style;
13
17
  modifyStyle?: Style;
14
18
  zIndex?: number;
15
19
  size?: number;
16
- };
17
- export declare const useDrawPolygon: (olMap: OLMap, options: DrawPolygonOptions) => {
20
+ }
21
+ export declare function useDrawPolygon(olMap: OLMap, options: DrawPolygonOptions): {
18
22
  inDraw: import('vue').Ref<boolean, boolean>;
19
23
  start: () => void;
20
24
  stop: () => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("ol/source/Vector"),k=require("ol/layer/Vector"),z=require("ol/interaction"),f=require("ol"),P=require("ol/geom"),l=require("vue"),V=require("../../utils/calculate/index.js"),O=require("../../utils/projection/index.js"),S=require("../common/index.js"),$=(n,e)=>{const m=l.ref(!0),d=l.ref([]),T=l.computed(()=>d.value.map(r=>r.getGeometry().getCoordinates())),t=new G,i=new k({source:t,style:e==null?void 0:e.style,zIndex:e==null?void 0:e.zIndex});n.addLayer(i);const c=new z.Draw({source:t,style:(e==null?void 0:e.drawStyle)||(e==null?void 0:e.style),type:"Polygon"});c.setActive(!1);const w=new z.Modify({source:t,style:(e==null?void 0:e.modifyStyle)||(e==null?void 0:e.style)}),s=new Set;n.addInteraction(c),l.onMounted(()=>{n.addInteraction(w)}),t.on("addfeature",()=>{e.size&&t.getFeatures().length>=e.size&&c.setActive(!1)}),t.on("removefeature",()=>{e.size&&t.getFeatures().length<e.size&&c.setActive(!0)});const h=()=>{s.forEach(r=>{n.removeOverlay(r)}),s.clear()};t.on("change",()=>{h(),t.getFeatures().forEach(r=>{const y=r.getGeometry(),a=V.getExtentCenter(O.mercatorExtentToWgs84(y.getExtent()));let u=document.createElement("div");e.deleteFeatureLabel?l.render(e.deleteFeatureLabel,u):u=S.createToolTipElement("删除区域"),u.addEventListener("click",()=>{t.removeFeature(r)});const L=new f.Overlay({position:O.wgs84ToMercator(a),positioning:"center-center",element:u});s.add(L),n.addOverlay(L);const v=y.getCoordinates()[0];v.length<3||v.forEach((I,C)=>{let g=document.createElement("div");e.deletePointLabel?l.render(e.deletePointLabel,g):g=S.createToolTipElement("删除点"),g.addEventListener("click",()=>{r.setGeometry(new P.Polygon([v.filter((j,D)=>D!==C)]))});const x=new f.Overlay({position:I,positioning:"top-center",offset:[0,-30],element:g});s.add(x),n.addOverlay(x)})})}),c.on("change:active",()=>{m.value=c.getActive()}),t.on("change",()=>{d.value=t.getFeatures()});const o=()=>{h(),n.removeLayer(i),n.removeInteraction(c),n.removeInteraction(w)},b=()=>{e.size&&d.value.length>=e.size||c.setActive(!0)},E=()=>{c.setActive(!1)},F=r=>{t.clear(),r==null||r.forEach(y=>{y.forEach(a=>{if(a.length<2)return;a[0]!=a[a.length-1]&&a.push(a[0]);const u=new f.Feature({geometry:new P.Polygon([a])});t.addFeature(u)})})},q=()=>{F(e.defaultCoordinates)};q();const A=()=>{t.clear(),E()};return l.onUnmounted(()=>{o()}),{inDraw:m,start:b,stop:E,clear:A,setFeatures:F,reset:q,features:d,coordinates:T,destroy:o}};exports.useDrawPolygon=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ol"),z=require("ol/geom"),P=require("ol/interaction"),j=require("ol/layer/Vector"),U=require("ol/source/Vector"),l=require("vue"),W=require("../../utils/calculate/index.js"),v=require("../../utils/style/index.js");require("ol/layer");require("ol/source");const T=require("../../utils/projection/index.js"),b=require("../common/index.js");function _(n,e){const m=l.ref(!0),u=l.ref([]),A=l.computed(()=>u.value.map(r=>r.getGeometry().getCoordinates())),o=e.styleOptions?v.createStyle(e.styleOptions):e==null?void 0:e.style,t=new U,w=new j({source:t,style:o,zIndex:e==null?void 0:e.zIndex});n.addLayer(w);const I=e.drawStyleOptions?v.createStyle(e.drawStyleOptions):e==null?void 0:e.drawStyle,c=new P.Draw({source:t,style:I||o,type:"Polygon"});c.setActive(!1);const C=e.modifyStyleOptions?v.createStyle(e.modifyStyleOptions):e==null?void 0:e.modifyStyle,S=new P.Modify({source:t,style:C||o}),d=new Set;n.addInteraction(c),l.onMounted(()=>{n.addInteraction(S)}),t.on("addfeature",()=>{e.size&&t.getFeatures().length>=e.size&&c.setActive(!1)}),t.on("removefeature",()=>{e.size&&t.getFeatures().length<e.size&&c.setActive(!0)});const h=()=>{d.forEach(r=>{n.removeOverlay(r)}),d.clear()};t.on("change",()=>{h(),t.getFeatures().forEach(r=>{const y=r.getGeometry(),a=W.getExtentCenter(T.mercatorExtentToWgs84(y.getExtent()));let s=document.createElement("div");e.deleteFeatureLabel?l.render(e.deleteFeatureLabel,s):s=b.createToolTipElement("删除区域"),s.addEventListener("click",()=>{t.removeFeature(r)});const x=new g.Overlay({position:T.wgs84ToMercator(a),positioning:"center-center",element:s});d.add(x),n.addOverlay(x);const f=y.getCoordinates()[0];f.length<3||f.forEach(($,k)=>{let i=document.createElement("div");e.deletePointLabel?l.render(e.deletePointLabel,i):i=b.createToolTipElement("删除点"),i.addEventListener("click",()=>{r.setGeometry(new z.Polygon([f.filter((B,V)=>V!==k)]))});const L=new g.Overlay({position:$,positioning:"top-center",offset:[0,-30],element:i});d.add(L),n.addOverlay(L)})})}),c.on("change:active",()=>{m.value=c.getActive()}),t.on("change",()=>{u.value=t.getFeatures()});const E=()=>{h(),n.removeLayer(w),n.removeInteraction(c),n.removeInteraction(S)},D=()=>{e.size&&u.value.length>=e.size||c.setActive(!0)},O=()=>{c.setActive(!1)},q=r=>{t.clear(),r==null||r.forEach(y=>{y.forEach(a=>{if(a.length<2)return;a[0]!==a[a.length-1]&&a.push(a[0]);const s=new g.Feature({geometry:new z.Polygon([a])});t.addFeature(s)})})},F=()=>{q(e.defaultCoordinates)};F();const G=()=>{t.clear(),O()};return l.onUnmounted(()=>{E()}),{inDraw:m,start:D,stop:O,clear:G,setFeatures:q,reset:F,features:u,coordinates:A,destroy:E}}exports.useDrawPolygon=_;
@@ -1,12 +1,12 @@
1
- import { Stroke } from 'ol/style';
2
- import { MaybeRef, Ref } from 'vue';
3
1
  import { Map as OLMap } from 'ol';
4
- export type UseGraticuleOptions = {
2
+ import { MaybeRef, Ref } from 'vue';
3
+ import { Stroke } from 'ol/style';
4
+ export interface UseGraticuleOptions {
5
5
  olMap: MaybeRef<OLMap | null | undefined>;
6
6
  strokeStyle?: Stroke;
7
7
  defaultShow?: boolean;
8
- };
9
- export declare const useGraticule: (options: UseGraticuleOptions) => {
8
+ }
9
+ export declare function useGraticule(options: UseGraticuleOptions): {
10
10
  showGraticule: Ref<boolean, boolean>;
11
11
  };
12
12
  export type UseGraticuleReturn = ReturnType<typeof useGraticule>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("ol/layer"),u=require("ol/style"),r=require("vue"),i=e=>{const l=r.ref(e.defaultShow||!1);let t=new s.Graticule({strokeStyle:e.strokeStyle||new u.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 s.Graticule({strokeStyle:new u.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"),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,11 +1,11 @@
1
1
  import { Map as OLMap } from 'ol';
2
2
  import { default as TileLayer } from 'ol/layer/Tile';
3
- export declare const useSwitchBaseLayer: (data: {
3
+ export declare function useSwitchBaseLayer(data: {
4
4
  olMap: OLMap;
5
5
  defaultLayerName?: string;
6
6
  layers: {
7
7
  [key: string]: TileLayer[];
8
8
  };
9
- }) => {
9
+ }): {
10
10
  visibleLayerName: import('vue').Ref<string, string>;
11
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),c=e=>{const s=a.ref(e.defaultLayerName||Object.keys(e.layers)[0]);return Object.values(e.layers).map(r=>{r.map(t=>{e.olMap.addLayer(t)})}),a.watch(s,()=>{Object.entries(e.layers).map(([r,t])=>{const i=r===s.value;t.map(l=>{l.setVisible(i)})})},{immediate:!0}),{visibleLayerName:s}};exports.useSwitchBaseLayer=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue");function l(e){const r=a.ref(e.defaultLayerName||Object.keys(e.layers)[0]);return Object.values(e.layers).forEach(s=>{s.forEach(t=>{e.olMap.addLayer(t)})}),a.watch(r,()=>{Object.entries(e.layers).forEach(([s,t])=>{const c=s===r.value;t.forEach(i=>{i.setVisible(c)})})},{immediate:!0}),{visibleLayerName:r}}exports.useSwitchBaseLayer=l;
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./components/n-ol-contextmenu/index.vue.js"),l=require("./components/ol-map/index.vue.js"),g=require("./components/ol-map/props.js"),s=require("./components/n-ol-pointermove/index.vue.js"),P=require("./composables/useGraticule/index.js"),S=require("./composables/useSwitchBaseLayer/index.js"),_=require("./composables/useDrawLineString/index.js"),y=require("./composables/useDrawPolygon/index.js"),T=require("./constants/distance.js"),i=require("./constants/projection.js"),n=require("./utils/layer/index.js"),r=require("./utils/calculate/index.js"),o=require("./utils/distance/index.js"),c=require("./utils/format/index.js"),t=require("./utils/projection/index.js"),E=require("./utils/realCircle/index.js"),a=require("./utils/style/index.js"),e=require("./utils/feature/index.js");exports.NOlContextmenu=u.default;exports.OlMap=l.default;exports.olMapInjectionKey=g.olMapInjectionKey;exports.NOlPointermove=s.default;exports.useGraticule=P.useGraticule;exports.useSwitchBaseLayer=S.useSwitchBaseLayer;exports.useDrawLineString=_.useDrawLineString;exports.useDrawPolygon=y.useDrawPolygon;exports.ONE_NM=T.ONE_NM;exports.EPSG_3857=i.EPSG_3857;exports.EPSG_4326=i.EPSG_4326;exports.WGS84Projection=i.WGS84Projection;exports.WebMercatorProjection=i.WebMercatorProjection;exports.createVectorLayer=n.createVectorLayer;exports.getBingLayer=n.getBingLayer;exports.getOSMLayer=n.getOSMLayer;exports.getTianDiTuLayer=n.getTianDiTuLayer;exports.getTianDiTuUrl=n.getTianDiTuUrl;exports.getAngle=r.getAngle;exports.getArea=r.getArea;exports.getCenter=r.getCenter;exports.getDestinationPoint=r.getDestinationPoint;exports.getExtentCenter=r.getExtentCenter;exports.getLineLength=r.getLineLength;exports.kmToNauticalMiles=o.kmToNauticalMiles;exports.nauticalMilesToKm=o.nauticalMilesToKm;exports.toOlAngle=c.toOlAngle;exports.toTurfAngle=c.toTurfAngle;exports.EPSG_3857ExtentToEPSG_4326=t.EPSG_3857ExtentToEPSG_4326;exports.EPSG_3857ToEPSG_4326=t.EPSG_3857ToEPSG_4326;exports.EPSG_4326ExtentToEPSG_3857=t.EPSG_4326ExtentToEPSG_3857;exports.EPSG_4326ToEPSG_3857=t.EPSG_4326ToEPSG_3857;exports.mercatorExtentToWgs84=t.mercatorExtentToWgs84;exports.mercatorToWgs84=t.mercatorToWgs84;exports.wgs84ExtentToMercator=t.wgs84ExtentToMercator;exports.wgs84ToMercator=t.wgs84ToMercator;exports.getRealCircleCoordinates=E.getRealCircleCoordinates;exports.createCircleStyle=a.createCircleStyle;exports.createStyle=a.createStyle;exports.createTextStyle=a.createTextStyle;exports.createCircle=e.createCircle;exports.createCircleFeature=e.createCircleFeature;exports.createFeature=e.createFeature;exports.createLineString=e.createLineString;exports.createLineStringFeature=e.createLineStringFeature;exports.createMultiLineString=e.createMultiLineString;exports.createMultiLineStringFeature=e.createMultiLineStringFeature;exports.createMultiPoint=e.createMultiPoint;exports.createMultiPointFeature=e.createMultiPointFeature;exports.createMultiPolygon=e.createMultiPolygon;exports.createMultiPolygonFeature=e.createMultiPolygonFeature;exports.createPoint=e.createPoint;exports.createPointFeature=e.createPointFeature;exports.createPolygon=e.createPolygon;exports.createPolygonFeature=e.createPolygonFeature;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./components/n-ol-contextmenu/index.vue.js"),l=require("./components/n-ol-pointermove/index.vue.js"),g=require("./components/ol-map/index.vue.js"),s=require("./components/ol-map/props.js"),P=require("./composables/useDrawLineString/index.js"),S=require("./composables/useDrawPolygon/index.js"),_=require("./composables/useGraticule/index.js"),y=require("./composables/useSwitchBaseLayer/index.js"),T=require("./constants/distance.js"),i=require("./constants/projection.js"),r=require("./utils/calculate/index.js"),o=require("./utils/distance/index.js"),e=require("./utils/feature/index.js"),c=require("./utils/format/index.js"),n=require("./utils/layer/index.js"),t=require("./utils/projection/index.js"),E=require("./utils/realCircle/index.js"),a=require("./utils/style/index.js");exports.NOlContextmenu=u.default;exports.NOlPointermove=l.default;exports.OlMap=g.default;exports.olMapInjectionKey=s.olMapInjectionKey;exports.useDrawLineString=P.useDrawLineString;exports.useDrawPolygon=S.useDrawPolygon;exports.useGraticule=_.useGraticule;exports.useSwitchBaseLayer=y.useSwitchBaseLayer;exports.ONE_NM=T.ONE_NM;exports.EPSG_3857=i.EPSG_3857;exports.EPSG_4326=i.EPSG_4326;exports.WGS84Projection=i.WGS84Projection;exports.WebMercatorProjection=i.WebMercatorProjection;exports.getAngle=r.getAngle;exports.getArea=r.getArea;exports.getCenter=r.getCenter;exports.getDestinationPoint=r.getDestinationPoint;exports.getExtentCenter=r.getExtentCenter;exports.getLineLength=r.getLineLength;exports.kmToNauticalMiles=o.kmToNauticalMiles;exports.nauticalMilesToKm=o.nauticalMilesToKm;exports.createCircle=e.createCircle;exports.createCircleFeature=e.createCircleFeature;exports.createFeature=e.createFeature;exports.createLineString=e.createLineString;exports.createLineStringFeature=e.createLineStringFeature;exports.createMultiLineString=e.createMultiLineString;exports.createMultiLineStringFeature=e.createMultiLineStringFeature;exports.createMultiPoint=e.createMultiPoint;exports.createMultiPointFeature=e.createMultiPointFeature;exports.createMultiPolygon=e.createMultiPolygon;exports.createMultiPolygonFeature=e.createMultiPolygonFeature;exports.createPoint=e.createPoint;exports.createPointFeature=e.createPointFeature;exports.createPolygon=e.createPolygon;exports.createPolygonFeature=e.createPolygonFeature;exports.toOlAngle=c.toOlAngle;exports.toTurfAngle=c.toTurfAngle;exports.createVectorLayer=n.createVectorLayer;exports.getBingLayer=n.getBingLayer;exports.getOSMLayer=n.getOSMLayer;exports.getTianDiTuLayer=n.getTianDiTuLayer;exports.getTianDiTuUrl=n.getTianDiTuUrl;exports.EPSG_3857ExtentToEPSG_4326=t.EPSG_3857ExtentToEPSG_4326;exports.EPSG_3857ToEPSG_4326=t.EPSG_3857ToEPSG_4326;exports.EPSG_4326ExtentToEPSG_3857=t.EPSG_4326ExtentToEPSG_3857;exports.EPSG_4326ToEPSG_3857=t.EPSG_4326ToEPSG_3857;exports.mercatorExtentToWgs84=t.mercatorExtentToWgs84;exports.mercatorToWgs84=t.mercatorToWgs84;exports.wgs84ExtentToMercator=t.wgs84ExtentToMercator;exports.wgs84ToMercator=t.wgs84ToMercator;exports.getRealCircleCoordinates=E.getRealCircleCoordinates;exports.createCircleStyle=a.createCircleStyle;exports.createStyle=a.createStyle;exports.createTextStyle=a.createTextStyle;
@@ -1,22 +1,24 @@
1
1
  import { Coordinate } from 'ol/coordinate';
2
2
  import { Extent } from 'ol/extent';
3
- /** 计算已知方位距离的目标点
3
+ /**
4
+ * 计算已知方位距离的目标点
4
5
  * @param coordinates 起点坐标 WGS84 EPSG:4326
5
6
  * @param distance 距离,单位为米
6
7
  * @param azimuth 方位角,单位为度
7
8
  * @returns 目标点坐标 WGS84 EPSG:4326
8
9
  */
9
- export declare const getDestinationPoint: (coordinates: Coordinate, distance: number, azimuth: number) => Coordinate;
10
- /** 计算线段的长度
10
+ export declare function getDestinationPoint(coordinates: Coordinate, distance: number, azimuth: number): Coordinate;
11
+ /**
12
+ * 计算线段的长度
11
13
  * @param coordinates 线段坐标 WGS84 EPSG:4326
12
14
  * @returns 线段长度,单位为米
13
15
  */
14
- export declare const getLineLength: (coordinates: Coordinate[]) => number;
16
+ export declare function getLineLength(coordinates: Coordinate[]): number;
15
17
  /** 计算面积 */
16
- export declare const getArea: (coordinates: Coordinate[][]) => number;
18
+ export declare function getArea(coordinates: Coordinate[][]): number;
17
19
  /** 计算2点之间的角度 */
18
- export declare const getAngle: (start: Coordinate, end: Coordinate) => number;
20
+ export declare function getAngle(start: Coordinate, end: Coordinate): number;
19
21
  /** 计算2点的中心点 */
20
- export declare const getCenter: (start: Coordinate, end: Coordinate) => Coordinate;
22
+ export declare function getCenter(start: Coordinate, end: Coordinate): Coordinate;
21
23
  /** 计算Extent中心点 */
22
- export declare const getExtentCenter: (extent: Extent) => Coordinate;
24
+ export declare function getExtentCenter(extent: Extent): Coordinate;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@turf/turf"),r=require("../format/index.js"),i=(e,t,g)=>n.destination(e,t,r.toTurfAngle(g),{units:"meters"}).geometry.coordinates,s=e=>{const t=n.lineString(e);return n.length(t,{units:"meters"})},u=e=>n.area(n.polygon(e)),c=(e,t)=>r.toOlAngle(n.bearing(e,t)),o=(e,t)=>n.midpoint(e,t).geometry.coordinates,a=e=>o([e[0],e[1]],[e[2],e[3]]);exports.getAngle=c;exports.getArea=u;exports.getCenter=o;exports.getDestinationPoint=i;exports.getExtentCenter=a;exports.getLineLength=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@turf/turf"),r=require("../format/index.js");function g(e,t,o){return n.destination(e,t,r.toTurfAngle(o),{units:"meters"}).geometry.coordinates}function u(e){const t=n.lineString(e);return n.length(t,{units:"meters"})}function s(e){return n.area(n.polygon(e))}function c(e,t){return r.toOlAngle(n.bearing(e,t))}function i(e,t){return n.midpoint(e,t).geometry.coordinates}function a(e){return i([e[0],e[1]],[e[2],e[3]])}exports.getAngle=c;exports.getArea=s;exports.getCenter=i;exports.getDestinationPoint=g;exports.getExtentCenter=a;exports.getLineLength=u;
@@ -1,4 +1,4 @@
1
1
  /** 公里转海里 */
2
- export declare const kmToNauticalMiles: (km: number) => number;
2
+ export declare function kmToNauticalMiles(km: number): number;
3
3
  /** 海里转公里 */
4
- export declare const nauticalMilesToKm: (nauticalMiles: number) => number;
4
+ export declare function nauticalMilesToKm(nauticalMiles: number): number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../constants/distance.js"),i=e=>e*1e3/t.ONE_NM,a=e=>e*t.ONE_NM/1e3;exports.kmToNauticalMiles=i;exports.nauticalMilesToKm=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../constants/distance.js");function i(e){return e*1e3/t.ONE_NM}function n(e){return e*t.ONE_NM/1e3}exports.kmToNauticalMiles=i;exports.nauticalMilesToKm=n;