cd-mapgis 1.0.64 → 1.0.65
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 +1 -1
- package/src/LayerUtil.js +16 -0
- package/src/index.js +3 -1
package/package.json
CHANGED
package/src/LayerUtil.js
CHANGED
|
@@ -14,6 +14,7 @@ import VectorLayer from 'ol/layer/Vector.js';
|
|
|
14
14
|
import StyleUtil from './StyleUtil.js';
|
|
15
15
|
import LineString from 'ol/geom/LineString.js';
|
|
16
16
|
import Polygon from 'ol/geom/Polygon.js';
|
|
17
|
+
import { WKT } from 'ol/format';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* 图层工具
|
|
@@ -207,6 +208,21 @@ export default class LayerUtil {
|
|
|
207
208
|
});
|
|
208
209
|
return { layer: layer, geometry: geometry };
|
|
209
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* 将单个wkt数据包装为一个图层
|
|
213
|
+
* @param {*} json
|
|
214
|
+
*/
|
|
215
|
+
static getWktLayer(p) {
|
|
216
|
+
let wktFormat = new WKT();
|
|
217
|
+
let geometry = wktFormat.readGeometry(p.data);
|
|
218
|
+
let feature = new Feature({ geometry: geometry });
|
|
219
|
+
let vectorSource = new VectorSource({ features: [feature] });
|
|
220
|
+
let layer = new VectorLayer({
|
|
221
|
+
source: vectorSource,
|
|
222
|
+
style: p.style
|
|
223
|
+
});
|
|
224
|
+
return { layer: layer, geometry: geometry };
|
|
225
|
+
}
|
|
210
226
|
/**
|
|
211
227
|
* [[116.4074, 39.9042], [121.4737, 31.2304]]
|
|
212
228
|
* @param {*} p
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import LayerUtil from './LayerUtil.js';
|
|
|
5
5
|
import Overlay from './Overlay.js';
|
|
6
6
|
import HttpUtil from './HttpUtil.js';
|
|
7
7
|
import InnerUtil from './InnerUtil.js';
|
|
8
|
+
import StyleUtil from './StyleUtil.js';
|
|
8
9
|
|
|
9
10
|
// 导出模块
|
|
10
11
|
export {
|
|
@@ -13,5 +14,6 @@ export {
|
|
|
13
14
|
LayerUtil,
|
|
14
15
|
Overlay,
|
|
15
16
|
HttpUtil,
|
|
16
|
-
InnerUtil
|
|
17
|
+
InnerUtil,
|
|
18
|
+
StyleUtil
|
|
17
19
|
};
|