my-openlayer 0.1.16 → 0.1.18

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.
@@ -58,6 +58,7 @@ export default class Polygon {
58
58
  features?.forEach(feature => {
59
59
  feature.set('type', options?.type);
60
60
  feature.set('layerName', options?.type);
61
+ const fillColor = options?.fillColorCallBack ? options.fillColorCallBack(feature) : options?.fillColor;
61
62
  const featureStyle = new Style({
62
63
  stroke: new Stroke({
63
64
  color: options?.strokeColor ?? '#EBEEF5',
@@ -65,10 +66,10 @@ export default class Polygon {
65
66
  lineDash: options?.lineDash,
66
67
  lineDashOffset: options?.lineDashOffset
67
68
  }),
68
- fill: new Fill({ color: options?.fillColor || 'rgba(255, 255, 255, 0.3)' }),
69
+ fill: new Fill({ color: fillColor ?? 'rgba(255, 255, 255, 0.3)' }),
69
70
  });
70
71
  if (options?.textVisible) {
71
- const text = options?.textValue || (options.nameKey ? feature.get(options.nameKey) : "");
72
+ const text = (options?.textCallBack ? options?.textCallBack(feature) : '') || (options.nameKey ? feature.get(options.nameKey) : "");
72
73
  featureStyle.setText(new Text({
73
74
  text: text,
74
75
  font: options?.textFont ?? '14px Calibri,sans-serif',
@@ -118,7 +119,7 @@ export default class Polygon {
118
119
  fill: new Fill({ color: newColor || options?.fillColor || 'rgba(255, 255, 255, 0.3)' }),
119
120
  });
120
121
  if (options?.textVisible) {
121
- const text = options?.textValue || (options.nameKey ? feature.get(options.nameKey) : "");
122
+ const text = (options?.textCallBack ? options?.textCallBack(feature) : '') || (options.nameKey ? feature.get(options.nameKey) : "");
122
123
  featureStyle.setText(new Text({
123
124
  text,
124
125
  font: options?.textFont ?? '14px Calibri,sans-serif',
package/dist/types.d.ts CHANGED
@@ -71,8 +71,9 @@ export interface OptionsType {
71
71
  lineDash?: number[];
72
72
  lineDashOffset?: number;
73
73
  fillColor?: string;
74
+ fillColorCallBack?: (feature: any) => string;
74
75
  textVisible?: boolean;
75
- textValue?: string;
76
+ textCallBack?: (feature: any) => string;
76
77
  textFont?: string;
77
78
  textFillColor?: string;
78
79
  textStrokeColor?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "my-openlayer",
3
3
  "private": false,
4
- "version": "0.1.16",
4
+ "version": "0.1.18",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",