cd-mapgis 1.0.74 → 1.0.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cd-mapgis",
3
- "version": "1.0.74",
3
+ "version": "1.0.75",
4
4
  "main": "./src/index.js",
5
5
  "types": "./src/index.d.ts",
6
6
  "type": "module",
package/src/LayerUtil.js CHANGED
@@ -202,7 +202,7 @@ export default class LayerUtil {
202
202
  let geometry = geoJSON.readGeometry(p.data);
203
203
  let feature = new Feature({ geometry: geometry });
204
204
  let vectorSource = new VectorSource({ features: [feature] });
205
- p.style = p.style ? StyleUtil.getPointStyle(p.style) : StyleUtil.getViewOnTemplayerStyle();
205
+ p.style = p.style ? StyleUtil.getCommStyle(p.style) : StyleUtil.getViewOnTemplayerStyle();
206
206
  let layer = new VectorLayer({
207
207
  source: vectorSource,
208
208
  style: p.style
package/src/StyleUtil.js CHANGED
@@ -159,4 +159,34 @@ export default class StyleUtil {
159
159
  }
160
160
  return new Style(styleParam);
161
161
  }
162
+ /**
163
+ * 通用样式配置
164
+ * @param {*} p
165
+ * @returns
166
+ */
167
+ static getCommStyle(p) {
168
+ let styleParam = {};
169
+ let fill = 'rgba(255, 255, 255, 0.2)';
170
+ let lineColor = 'rgba(0, 0, 255, 1)';
171
+ let lineWidth = 2;
172
+ if (p.style) {
173
+ if (p.style.fillColor) fill = p.style.fillColor;
174
+ if (p.style.lineColor) lineColor = p.style.lineColor;
175
+ if (p.style.lineWidth) lineWidth = p.style.lineWidth;
176
+ }
177
+ styleParam.fill = new Fill({
178
+ color: fill
179
+ });
180
+ styleParam.stroke = new Stroke({
181
+ color: lineColor,
182
+ width: lineWidth
183
+ });
184
+ if (p.img) {
185
+ styleParam.image = StyleUtil.getIcon(p.img);
186
+ }
187
+ if (p.text) {
188
+ styleParam.text = StyleUtil.getText(p.text);
189
+ }
190
+ return new Style(styleParam);
191
+ }
162
192
  }