map-ol-utils 0.0.27 → 0.0.28
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/dist/index.cjs +20 -3
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -162,6 +162,24 @@ var import_control = require("ol/control");
|
|
|
162
162
|
// src/layer-utils.ts
|
|
163
163
|
var import_gcoord = __toESM(require("gcoord"), 1);
|
|
164
164
|
var import_geom = require("ol/geom");
|
|
165
|
+
|
|
166
|
+
// src/helper.ts
|
|
167
|
+
var hexToRgba = (hex, alpha) => {
|
|
168
|
+
if (hex.startsWith("#")) {
|
|
169
|
+
let tempHex = hex.replace("#", "");
|
|
170
|
+
if (tempHex.length === 3) {
|
|
171
|
+
tempHex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
172
|
+
}
|
|
173
|
+
const r = parseInt(tempHex.substring(0, 2), 16);
|
|
174
|
+
const g = parseInt(tempHex.substring(2, 4), 16);
|
|
175
|
+
const b = parseInt(tempHex.substring(4, 6), 16);
|
|
176
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
177
|
+
} else {
|
|
178
|
+
return hex;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/layer-utils.ts
|
|
165
183
|
var import_format2 = require("ol/format");
|
|
166
184
|
var import_ol = require("ol");
|
|
167
185
|
var import_interaction = require("ol/interaction");
|
|
@@ -169,7 +187,6 @@ var import_Vector = __toESM(require("ol/layer/Vector"), 1);
|
|
|
169
187
|
var import_Vector2 = __toESM(require("ol/source/Vector"), 1);
|
|
170
188
|
var import_condition = require("ol/events/condition");
|
|
171
189
|
var import_style = require("ol/style");
|
|
172
|
-
var import_ol2 = __toESM(require("ol/dist/ol"), 1);
|
|
173
190
|
var removeOverlays = (key = "") => {
|
|
174
191
|
if (instance) {
|
|
175
192
|
const overlays = instance.getOverlays().getArray().filter((overlay) => overlay.get(key || "position"));
|
|
@@ -225,7 +242,7 @@ var assembleGeoJson = (dataList, config) => {
|
|
|
225
242
|
return import_gcoord.default.transform({ type: "FeatureCollection", features: tempList }, import_gcoord.default.GCJ02, import_gcoord.default.WGS84);
|
|
226
243
|
};
|
|
227
244
|
var createVectorStyle = (data, config) => {
|
|
228
|
-
const { isLine, colorMap, fillColor, colorKey, strokeColor, strokeWeight } = config || {};
|
|
245
|
+
const { isLine, colorMap, fillColor, colorKey, strokeColor, strokeWeight, fillOpacity } = config || {};
|
|
229
246
|
const style = new import_style.Style({
|
|
230
247
|
stroke: new import_style.Stroke({
|
|
231
248
|
width: strokeWeight,
|
|
@@ -235,7 +252,7 @@ var createVectorStyle = (data, config) => {
|
|
|
235
252
|
if (!isLine) {
|
|
236
253
|
style.setFill(
|
|
237
254
|
new import_style.Fill({
|
|
238
|
-
color: colorKey ? (colorMap == null ? void 0 : colorMap.get(data[colorKey])) || fillColor : fillColor
|
|
255
|
+
color: hexToRgba((colorKey ? (colorMap == null ? void 0 : colorMap.get(data[colorKey])) || fillColor : fillColor) || "", fillOpacity || 1)
|
|
239
256
|
})
|
|
240
257
|
);
|
|
241
258
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -107,6 +107,24 @@ import { defaults } from "ol/control";
|
|
|
107
107
|
// src/layer-utils.ts
|
|
108
108
|
import gcoord from "gcoord";
|
|
109
109
|
import { Point } from "ol/geom";
|
|
110
|
+
|
|
111
|
+
// src/helper.ts
|
|
112
|
+
var hexToRgba = (hex, alpha) => {
|
|
113
|
+
if (hex.startsWith("#")) {
|
|
114
|
+
let tempHex = hex.replace("#", "");
|
|
115
|
+
if (tempHex.length === 3) {
|
|
116
|
+
tempHex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
117
|
+
}
|
|
118
|
+
const r = parseInt(tempHex.substring(0, 2), 16);
|
|
119
|
+
const g = parseInt(tempHex.substring(2, 4), 16);
|
|
120
|
+
const b = parseInt(tempHex.substring(4, 6), 16);
|
|
121
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
122
|
+
} else {
|
|
123
|
+
return hex;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/layer-utils.ts
|
|
110
128
|
import { GeoJSON } from "ol/format";
|
|
111
129
|
import { Feature, Overlay } from "ol";
|
|
112
130
|
import { Select } from "ol/interaction";
|
|
@@ -114,7 +132,6 @@ import VectorLayer from "ol/layer/Vector";
|
|
|
114
132
|
import VectorSource from "ol/source/Vector";
|
|
115
133
|
import { click } from "ol/events/condition";
|
|
116
134
|
import { Fill, Icon, Stroke, Style } from "ol/style";
|
|
117
|
-
import ol from "ol/dist/ol";
|
|
118
135
|
var removeOverlays = (key = "") => {
|
|
119
136
|
if (instance) {
|
|
120
137
|
const overlays = instance.getOverlays().getArray().filter((overlay) => overlay.get(key || "position"));
|
|
@@ -170,7 +187,7 @@ var assembleGeoJson = (dataList, config) => {
|
|
|
170
187
|
return gcoord.transform({ type: "FeatureCollection", features: tempList }, gcoord.GCJ02, gcoord.WGS84);
|
|
171
188
|
};
|
|
172
189
|
var createVectorStyle = (data, config) => {
|
|
173
|
-
const { isLine, colorMap, fillColor, colorKey, strokeColor, strokeWeight } = config || {};
|
|
190
|
+
const { isLine, colorMap, fillColor, colorKey, strokeColor, strokeWeight, fillOpacity } = config || {};
|
|
174
191
|
const style = new Style({
|
|
175
192
|
stroke: new Stroke({
|
|
176
193
|
width: strokeWeight,
|
|
@@ -180,7 +197,7 @@ var createVectorStyle = (data, config) => {
|
|
|
180
197
|
if (!isLine) {
|
|
181
198
|
style.setFill(
|
|
182
199
|
new Fill({
|
|
183
|
-
color: colorKey ? (colorMap == null ? void 0 : colorMap.get(data[colorKey])) || fillColor : fillColor
|
|
200
|
+
color: hexToRgba((colorKey ? (colorMap == null ? void 0 : colorMap.get(data[colorKey])) || fillColor : fillColor) || "", fillOpacity || 1)
|
|
184
201
|
})
|
|
185
202
|
);
|
|
186
203
|
}
|