@summeruse/ol 0.3.2 → 0.3.3

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,5 +1,12 @@
1
1
  # @summeruse/ol
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - a224dda: refactor(style): 优化样式创建逻辑以支持直接传入样式对象
8
+ - 2085d50: refactor(utils/layer): 优化矢量图层创建函数,支持直接传入 style 和 source
9
+
3
10
  ## 0.3.2
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -261,13 +261,13 @@ function createTextStyle(r) {
261
261
  });
262
262
  }
263
263
  function createStyle(r) {
264
- let { fillOptions: l, strokeOptions: u, iconOptions: d, circleOptions: f, textOptions: p,...m } = r, h = l ? new Fill(l) : void 0, g = u ? new Stroke(u) : void 0, _ = d ? new Icon(d) : void 0, v = f ? createCircleStyle(f) : void 0, y = p ? createTextStyle(p) : void 0;
264
+ let { fillOptions: l, strokeOptions: u, iconOptions: d, circleOptions: f, textOptions: p, stroke: m, image: h, fill: g, text: _,...v } = r, y = g || (l ? new Fill(l) : void 0), b = m || (u ? new Stroke(u) : void 0), x = h || (d ? new Icon(d) : f ? createCircleStyle(f) : void 0), S = _ || (p ? createTextStyle(p) : void 0);
265
265
  return new Style({
266
- ...m,
267
- fill: h,
268
- stroke: g,
269
- image: _ || v,
270
- text: y
266
+ ...v,
267
+ fill: y,
268
+ stroke: b,
269
+ image: x,
270
+ text: S
271
271
  });
272
272
  }
273
273
  function createPoint(r) {
@@ -388,23 +388,23 @@ function createVectorSource(r) {
388
388
  return new VectorSource({ ...r });
389
389
  }
390
390
  function createVectorLayer(r) {
391
- let { styleOptions: l, sourceOptions: u,...d } = r || {}, f = l ? createStyle(l) : void 0, p = createVectorSource(u);
391
+ let { styleOptions: l, sourceOptions: u, style: d, source: f,...p } = r || {}, m = d || (l ? createStyle(l) : void 0), h = f || createVectorSource(u);
392
392
  return {
393
- source: p,
393
+ source: h,
394
394
  layer: new VectorLayer({
395
- source: p,
396
- ...d,
397
- style: f || d.style
395
+ ...p,
396
+ source: h,
397
+ style: m
398
398
  })
399
399
  };
400
400
  }
401
401
  function createWebGLVectorLayer(r) {
402
- let { style: l, sourceOptions: u,...d } = r, f = createVectorSource(u);
402
+ let { style: l, source: u, sourceOptions: d,...f } = r, p = u || createVectorSource(d);
403
403
  return {
404
- source: f,
404
+ source: p,
405
405
  layer: new WebGLVectorLayer({
406
- source: f,
407
- ...d,
406
+ ...f,
407
+ source: p,
408
408
  style: l
409
409
  })
410
410
  };
@@ -6,64 +6,64 @@ import { Tile } from "ol/layer";
6
6
  import WebGLVectorLayer from "ol/layer/WebGLVector";
7
7
  import { BingMaps, OSM, XYZ } from "ol/source";
8
8
  function createTianDiTuUrl(e) {
9
- let { type: d = "img", projection: f = WebMercatorProjection, key: p } = e, m = e.url || "https://t{0-4}.tianditu.gov.cn", h = `&tk=${p}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
10
- return `${m}/${d}_${f === "EPSG:4326" ? "c" : f === "EPSG:3857" ? "w" : "c"}/wmts?LAYER=${d}${h}`;
9
+ let { type: l = "img", projection: u = WebMercatorProjection, key: d } = e, f = e.url || "https://t{0-4}.tianditu.gov.cn", p = `&tk=${d}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
10
+ return `${f}/${l}_${u === "EPSG:4326" ? "c" : u === "EPSG:3857" ? "w" : "c"}/wmts?LAYER=${l}${p}`;
11
11
  }
12
12
  function createTianDiTuLayer(e) {
13
- let { layerOptions: u, sourceOptions: d,...f } = e;
13
+ let { layerOptions: c, sourceOptions: l,...u } = e;
14
14
  return new Tile({
15
15
  source: new XYZ({
16
- url: createTianDiTuUrl(f),
17
- projection: f.projection,
16
+ url: createTianDiTuUrl(u),
17
+ projection: u.projection,
18
18
  crossOrigin: "Anonymous",
19
- ...d
19
+ ...l
20
20
  }),
21
- ...u
21
+ ...c
22
22
  });
23
23
  }
24
- function createBingLayer({ name: e, key: u, layerOptions: d, sourceOptions: f }) {
24
+ function createBingLayer({ name: e, key: c, layerOptions: l, sourceOptions: u }) {
25
25
  return new Tile({
26
26
  source: new BingMaps({
27
- key: u,
27
+ key: c,
28
28
  imagerySet: e,
29
29
  placeholderTiles: !1,
30
- ...f
30
+ ...u
31
31
  }),
32
- ...d
32
+ ...l
33
33
  });
34
34
  }
35
35
  function createOpenStreetMapLayer(e) {
36
- let { layerOptions: u, sourceOptions: d } = e || {};
36
+ let { layerOptions: c, sourceOptions: l } = e || {};
37
37
  return new Tile({
38
38
  source: new OSM({
39
39
  crossOrigin: "Anonymous",
40
- ...d
40
+ ...l
41
41
  }),
42
- ...u
42
+ ...c
43
43
  });
44
44
  }
45
45
  function createVectorSource(e) {
46
46
  return new VectorSource({ ...e });
47
47
  }
48
48
  function createVectorLayer(e) {
49
- let { styleOptions: u, sourceOptions: p,...m } = e || {}, h = u ? createStyle(u) : void 0, g = createVectorSource(p);
49
+ let { styleOptions: c, sourceOptions: d, style: f, source: p,...m } = e || {}, h = f || (c ? createStyle(c) : void 0), g = p || createVectorSource(d);
50
50
  return {
51
51
  source: g,
52
52
  layer: new VectorLayer({
53
- source: g,
54
53
  ...m,
55
- style: h || m.style
54
+ source: g,
55
+ style: h
56
56
  })
57
57
  };
58
58
  }
59
59
  function createWebGLVectorLayer(e) {
60
- let { style: u, sourceOptions: d,...f } = e, p = createVectorSource(d);
60
+ let { style: c, source: l, sourceOptions: u,...d } = e, f = l || createVectorSource(u);
61
61
  return {
62
- source: p,
62
+ source: f,
63
63
  layer: new WebGLVectorLayer({
64
- source: p,
65
- ...f,
66
- style: u
64
+ ...d,
65
+ source: f,
66
+ style: c
67
67
  })
68
68
  };
69
69
  }
@@ -18,13 +18,13 @@ function createTextStyle(e) {
18
18
  });
19
19
  }
20
20
  function createStyle(e) {
21
- let { fillOptions: a, strokeOptions: c, iconOptions: l, circleOptions: u, textOptions: d,...f } = e, p = a ? new Fill(a) : void 0, m = c ? new Stroke(c) : void 0, h = l ? new Icon(l) : void 0, g = u ? createCircleStyle(u) : void 0, _ = d ? createTextStyle(d) : void 0;
21
+ let { fillOptions: a, strokeOptions: c, iconOptions: l, circleOptions: u, textOptions: d, stroke: f, image: p, fill: m, text: h,...g } = e, _ = m || (a ? new Fill(a) : void 0), v = f || (c ? new Stroke(c) : void 0), y = p || (l ? new Icon(l) : u ? createCircleStyle(u) : void 0), b = h || (d ? createTextStyle(d) : void 0);
22
22
  return new Style({
23
- ...f,
24
- fill: p,
25
- stroke: m,
26
- image: h || g,
27
- text: _
23
+ ...g,
24
+ fill: _,
25
+ stroke: v,
26
+ image: y,
27
+ text: b
28
28
  });
29
29
  }
30
30
  export { createCircleStyle, createStyle, createTextStyle };
@@ -1 +1 @@
1
- const e=require(`../../_virtual/rolldown_runtime.js`),t=require(`../../constants/projection.js`),n=require(`../style/index.js`);let r=require(`ol/layer/Vector`);r=e.__toESM(r);let i=require(`ol/source/Vector`);i=e.__toESM(i);let a=require(`ol/layer`);a=e.__toESM(a);let o=require(`ol/layer/WebGLVector`);o=e.__toESM(o);let s=require(`ol/source`);s=e.__toESM(s);function c(e){let{type:n=`img`,projection:r=t.WebMercatorProjection,key:i}=e,a=e.url||`https://t{0-4}.tianditu.gov.cn`,o=`&tk=${i}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;return`${a}/${n}_${r===`EPSG:4326`?`c`:r===`EPSG:3857`?`w`:`c`}/wmts?LAYER=${n}${o}`}function l(e){let{layerOptions:t,sourceOptions:n,...r}=e;return new a.Tile({source:new s.XYZ({url:c(r),projection:r.projection,crossOrigin:`Anonymous`,...n}),...t})}function u({name:e,key:t,layerOptions:n,sourceOptions:r}){return new a.Tile({source:new s.BingMaps({key:t,imagerySet:e,placeholderTiles:!1,...r}),...n})}function d(e){let{layerOptions:t,sourceOptions:n}=e||{};return new a.Tile({source:new s.OSM({crossOrigin:`Anonymous`,...n}),...t})}function f(e){return new i.default({...e})}function p(e){let{styleOptions:t,sourceOptions:i,...a}=e||{},o=t?n.createStyle(t):void 0,s=f(i);return{source:s,layer:new r.default({source:s,...a,style:o||a.style})}}function m(e){let{style:t,sourceOptions:n,...r}=e,i=f(n);return{source:i,layer:new o.default({source:i,...r,style:t})}}exports.createBingLayer=u,exports.createOpenStreetMapLayer=d,exports.createTianDiTuLayer=l,exports.createTianDiTuUrl=c,exports.createVectorLayer=p,exports.createVectorSource=f,exports.createWebGLVectorLayer=m;
1
+ const e=require(`../../_virtual/rolldown_runtime.js`),t=require(`../../constants/projection.js`),n=require(`../style/index.js`);let r=require(`ol/layer/Vector`);r=e.__toESM(r);let i=require(`ol/source/Vector`);i=e.__toESM(i);let a=require(`ol/layer`);a=e.__toESM(a);let o=require(`ol/layer/WebGLVector`);o=e.__toESM(o);let s=require(`ol/source`);s=e.__toESM(s);function c(e){let{type:n=`img`,projection:r=t.WebMercatorProjection,key:i}=e,a=e.url||`https://t{0-4}.tianditu.gov.cn`,o=`&tk=${i}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;return`${a}/${n}_${r===`EPSG:4326`?`c`:r===`EPSG:3857`?`w`:`c`}/wmts?LAYER=${n}${o}`}function l(e){let{layerOptions:t,sourceOptions:n,...r}=e;return new a.Tile({source:new s.XYZ({url:c(r),projection:r.projection,crossOrigin:`Anonymous`,...n}),...t})}function u({name:e,key:t,layerOptions:n,sourceOptions:r}){return new a.Tile({source:new s.BingMaps({key:t,imagerySet:e,placeholderTiles:!1,...r}),...n})}function d(e){let{layerOptions:t,sourceOptions:n}=e||{};return new a.Tile({source:new s.OSM({crossOrigin:`Anonymous`,...n}),...t})}function f(e){return new i.default({...e})}function p(e){let{styleOptions:t,sourceOptions:i,style:a,source:o,...s}=e||{},c=a||(t?n.createStyle(t):void 0),l=o||f(i);return{source:l,layer:new r.default({...s,source:l,style:c})}}function m(e){let{style:t,source:n,sourceOptions:r,...i}=e,a=n||f(r);return{source:a,layer:new o.default({...i,source:a,style:t})}}exports.createBingLayer=u,exports.createOpenStreetMapLayer=d,exports.createTianDiTuLayer=l,exports.createTianDiTuUrl=c,exports.createVectorLayer=p,exports.createVectorSource=f,exports.createWebGLVectorLayer=m;
@@ -1 +1 @@
1
- const e=require(`../../_virtual/rolldown_runtime.js`);let t=require(`ol/style`);t=e.__toESM(t);function n(e){let{fillOptions:n,strokeOptions:r,...i}=e;return new t.Circle({...i,fill:n?new t.Fill(n):void 0,stroke:r?new t.Stroke(r):void 0})}function r(e){let{fillOptions:n,strokeOptions:r,backgroundFillOptions:i,backgroundStrokeOptions:a,...o}=e;return new t.Text({...o,fill:n?new t.Fill(n):void 0,stroke:r?new t.Stroke(r):void 0,backgroundFill:i?new t.Fill(i):void 0,backgroundStroke:a?new t.Stroke(a):void 0})}function i(e){let{fillOptions:i,strokeOptions:a,iconOptions:o,circleOptions:s,textOptions:c,...l}=e,u=i?new t.Fill(i):void 0,d=a?new t.Stroke(a):void 0,f=o?new t.Icon(o):void 0,p=s?n(s):void 0,m=c?r(c):void 0;return new t.Style({...l,fill:u,stroke:d,image:f||p,text:m})}exports.createCircleStyle=n,exports.createStyle=i,exports.createTextStyle=r;
1
+ const e=require(`../../_virtual/rolldown_runtime.js`);let t=require(`ol/style`);t=e.__toESM(t);function n(e){let{fillOptions:n,strokeOptions:r,...i}=e;return new t.Circle({...i,fill:n?new t.Fill(n):void 0,stroke:r?new t.Stroke(r):void 0})}function r(e){let{fillOptions:n,strokeOptions:r,backgroundFillOptions:i,backgroundStrokeOptions:a,...o}=e;return new t.Text({...o,fill:n?new t.Fill(n):void 0,stroke:r?new t.Stroke(r):void 0,backgroundFill:i?new t.Fill(i):void 0,backgroundStroke:a?new t.Stroke(a):void 0})}function i(e){let{fillOptions:i,strokeOptions:a,iconOptions:o,circleOptions:s,textOptions:c,stroke:l,image:u,fill:d,text:f,...p}=e,m=d||(i?new t.Fill(i):void 0),h=l||(a?new t.Stroke(a):void 0),g=u||(o?new t.Icon(o):s?n(s):void 0),_=f||(c?r(c):void 0);return new t.Style({...p,fill:m,stroke:h,image:g,text:_})}exports.createCircleStyle=n,exports.createStyle=i,exports.createTextStyle=r;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@summeruse/ol",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "description": "",
6
6
  "author": "finalsummer",
7
7
  "license": "ISC",