my-openlayer 2.4.12 → 2.5.1
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 +251 -251
- package/LICENSE +21 -21
- package/MyOl.d.ts +9 -9
- package/MyOl.js +17 -14
- package/README.md +174 -148
- package/core/line/Line.d.ts +40 -0
- package/core/line/Line.js +144 -0
- package/core/line/LineFeatureFactory.d.ts +17 -0
- package/core/line/LineFeatureFactory.js +75 -0
- package/core/line/LineFlowAnimator.d.ts +53 -0
- package/core/line/LineFlowAnimator.js +297 -0
- package/core/line/LineStyleFactory.d.ts +43 -0
- package/core/line/LineStyleFactory.js +135 -0
- package/core/{RiverLayerManager.d.ts → line/RiverLayerManager.d.ts} +2 -2
- package/core/{RiverLayerManager.js → line/RiverLayerManager.js} +3 -5
- package/core/line/index.d.ts +6 -0
- package/core/line/index.js +5 -0
- package/core/{ConfigManager.d.ts → map/ConfigManager.d.ts} +25 -1
- package/core/{ConfigManager.js → map/ConfigManager.js} +22 -1
- package/core/{EventManager.d.ts → map/EventManager.d.ts} +1 -1
- package/core/{EventManager.js → map/EventManager.js} +2 -2
- package/core/{MapBaseLayers.d.ts → map/MapBaseLayers.d.ts} +1 -1
- package/core/{MapBaseLayers.js → map/MapBaseLayers.js} +3 -3
- package/core/{MapTools.d.ts → map/MapTools.d.ts} +5 -2
- package/core/{MapTools.js → map/MapTools.js} +11 -5
- package/core/{MeasureHandler.d.ts → map/MeasureHandler.d.ts} +1 -1
- package/core/{MeasureHandler.js → map/MeasureHandler.js} +41 -41
- package/core/map/index.d.ts +5 -0
- package/core/map/index.js +5 -0
- package/core/{Point.d.ts → point/Point.d.ts} +6 -14
- package/core/point/Point.js +272 -0
- package/core/point/PointClusterLayer.d.ts +10 -0
- package/core/point/PointClusterLayer.js +52 -0
- package/core/point/PointOverlay.d.ts +13 -0
- package/core/point/PointOverlay.js +57 -0
- package/core/point/PointPulseLayer.d.ts +13 -0
- package/core/point/PointPulseLayer.js +207 -0
- package/core/point/index.d.ts +4 -0
- package/core/point/index.js +4 -0
- package/core/{Polygon.d.ts → polygon/Polygon.d.ts} +4 -50
- package/core/polygon/Polygon.js +248 -0
- package/core/polygon/PolygonHeatmapLayer.d.ts +11 -0
- package/core/polygon/PolygonHeatmapLayer.js +40 -0
- package/core/polygon/PolygonImageLayer.d.ts +9 -0
- package/core/polygon/PolygonImageLayer.js +61 -0
- package/core/polygon/PolygonMaskLayer.d.ts +20 -0
- package/core/polygon/PolygonMaskLayer.js +107 -0
- package/core/polygon/PolygonStyleFactory.d.ts +12 -0
- package/core/polygon/PolygonStyleFactory.js +100 -0
- package/core/polygon/index.d.ts +5 -0
- package/core/polygon/index.js +5 -0
- package/core/{SelectHandler.d.ts → select/SelectHandler.d.ts} +2 -3
- package/core/{SelectHandler.js → select/SelectHandler.js} +4 -4
- package/core/select/index.d.ts +1 -0
- package/core/select/index.js +1 -0
- package/core/{VueTemplatePoint.d.ts → vue-template-point/VueTemplatePoint.d.ts} +1 -1
- package/core/{VueTemplatePoint.js → vue-template-point/VueTemplatePoint.js} +4 -4
- package/core/vue-template-point/index.d.ts +1 -0
- package/core/vue-template-point/index.js +1 -0
- package/docs/.vitepress/config.mts +57 -57
- package/docs/ConfigManager.md +71 -71
- package/docs/ErrorHandler.md +106 -106
- package/docs/EventManager.md +142 -142
- package/docs/Line.md +215 -187
- package/docs/MapBaseLayers.md +198 -198
- package/docs/MapTools.md +172 -172
- package/docs/MeasureHandler.md +87 -87
- package/docs/MyOl.md +247 -247
- package/docs/Point.md +136 -136
- package/docs/Polygon.md +241 -241
- package/docs/RiverLayerManager.md +187 -187
- package/docs/SelectHandler.md +147 -147
- package/docs/ValidationUtils.md +83 -83
- package/docs/VueTemplatePoint.md +214 -214
- package/docs/index.md +73 -73
- package/index.d.ts +10 -15
- package/index.js +7 -13
- package/package.json +11 -1
- package/types/base.d.ts +47 -0
- package/types/base.js +1 -0
- package/types/common.d.ts +59 -0
- package/types/common.js +1 -0
- package/types/index.d.ts +9 -0
- package/types/index.js +1 -0
- package/types/line.d.ts +41 -0
- package/types/line.js +1 -0
- package/types/map.d.ts +77 -0
- package/types/map.js +1 -0
- package/types/point.d.ts +54 -0
- package/types/point.js +1 -0
- package/types/polygon.d.ts +8 -0
- package/types/polygon.js +1 -0
- package/types/select.d.ts +25 -0
- package/types/select.js +1 -0
- package/types/vue-template-point.d.ts +54 -0
- package/{types.js → types/vue-template-point.js} +0 -3
- package/utils/ProjectionUtils.d.ts +28 -0
- package/utils/ProjectionUtils.js +34 -0
- package/utils/ValidationUtils.d.ts +33 -86
- package/utils/ValidationUtils.js +60 -165
- package/core/Line.d.ts +0 -49
- package/core/Line.js +0 -114
- package/core/Point.js +0 -560
- package/core/Polygon.js +0 -646
- package/docs/.vitepress/dist/404.html +0 -22
- package/docs/.vitepress/dist/ConfigManager.html +0 -46
- package/docs/.vitepress/dist/ErrorHandler.html +0 -52
- package/docs/.vitepress/dist/EventManager.html +0 -58
- package/docs/.vitepress/dist/Line.html +0 -92
- package/docs/.vitepress/dist/MapBaseLayers.html +0 -52
- package/docs/.vitepress/dist/MapTools.html +0 -81
- package/docs/.vitepress/dist/MeasureHandler.html +0 -32
- package/docs/.vitepress/dist/MyOl.html +0 -62
- package/docs/.vitepress/dist/Point.html +0 -81
- package/docs/.vitepress/dist/Polygon.html +0 -102
- package/docs/.vitepress/dist/RiverLayerManager.html +0 -66
- package/docs/.vitepress/dist/SelectHandler.html +0 -46
- package/docs/.vitepress/dist/ValidationUtils.html +0 -47
- package/docs/.vitepress/dist/VueTemplatePoint.html +0 -112
- package/docs/.vitepress/dist/assets/ConfigManager.md.BOMdGTaa.js +0 -22
- package/docs/.vitepress/dist/assets/ConfigManager.md.BOMdGTaa.lean.js +0 -1
- package/docs/.vitepress/dist/assets/ErrorHandler.md.yUiuJ9w9.js +0 -28
- package/docs/.vitepress/dist/assets/ErrorHandler.md.yUiuJ9w9.lean.js +0 -1
- package/docs/.vitepress/dist/assets/EventManager.md.BhCUVy1f.js +0 -34
- package/docs/.vitepress/dist/assets/EventManager.md.BhCUVy1f.lean.js +0 -1
- package/docs/.vitepress/dist/assets/Line.md.BAQOzmSt.js +0 -68
- package/docs/.vitepress/dist/assets/Line.md.BAQOzmSt.lean.js +0 -1
- package/docs/.vitepress/dist/assets/MapBaseLayers.md.Bw0L_m0b.js +0 -28
- package/docs/.vitepress/dist/assets/MapBaseLayers.md.Bw0L_m0b.lean.js +0 -1
- package/docs/.vitepress/dist/assets/MapTools.md.DaYgiDPe.js +0 -57
- package/docs/.vitepress/dist/assets/MapTools.md.DaYgiDPe.lean.js +0 -1
- package/docs/.vitepress/dist/assets/MeasureHandler.md.7Sf4ymRv.js +0 -8
- package/docs/.vitepress/dist/assets/MeasureHandler.md.7Sf4ymRv.lean.js +0 -1
- package/docs/.vitepress/dist/assets/MyOl.md.D-14Gzjy.js +0 -38
- package/docs/.vitepress/dist/assets/MyOl.md.D-14Gzjy.lean.js +0 -1
- package/docs/.vitepress/dist/assets/Point.md.Bi9juuuv.js +0 -57
- package/docs/.vitepress/dist/assets/Point.md.Bi9juuuv.lean.js +0 -1
- package/docs/.vitepress/dist/assets/Polygon.md.-JIqEvzD.js +0 -78
- package/docs/.vitepress/dist/assets/Polygon.md.-JIqEvzD.lean.js +0 -1
- package/docs/.vitepress/dist/assets/RiverLayerManager.md.CfUu2RxH.js +0 -42
- package/docs/.vitepress/dist/assets/RiverLayerManager.md.CfUu2RxH.lean.js +0 -1
- package/docs/.vitepress/dist/assets/SelectHandler.md.COR4ez_p.js +0 -22
- package/docs/.vitepress/dist/assets/SelectHandler.md.COR4ez_p.lean.js +0 -1
- package/docs/.vitepress/dist/assets/ValidationUtils.md.ReTVWa73.js +0 -23
- package/docs/.vitepress/dist/assets/ValidationUtils.md.ReTVWa73.lean.js +0 -1
- package/docs/.vitepress/dist/assets/VueTemplatePoint.md.CtxSb5Pm.js +0 -88
- package/docs/.vitepress/dist/assets/VueTemplatePoint.md.CtxSb5Pm.lean.js +0 -1
- package/docs/.vitepress/dist/assets/app.YvjVuxaB.js +0 -1
- package/docs/.vitepress/dist/assets/chunks/framework.C_W0ODpn.js +0 -18
- package/docs/.vitepress/dist/assets/chunks/theme.Bf87fILP.js +0 -1
- package/docs/.vitepress/dist/assets/index.md.BJz6tHSr.js +0 -26
- package/docs/.vitepress/dist/assets/index.md.BJz6tHSr.lean.js +0 -1
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/docs/.vitepress/dist/assets/style.C2pAQzDq.css +0 -1
- package/docs/.vitepress/dist/hashmap.json +0 -1
- package/docs/.vitepress/dist/index.html +0 -50
- package/docs/.vitepress/dist/vp-icons.css +0 -1
- package/types.d.ts +0 -431
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Feature from "ol/Feature";
|
|
2
|
+
import { Geometry } from "ol/geom";
|
|
3
|
+
import Map from "ol/Map";
|
|
4
|
+
import VectorLayer from "ol/layer/Vector";
|
|
5
|
+
import VectorSource from "ol/source/Vector";
|
|
6
|
+
import type { MapJSONData, MaskLayerOptions } from "../../types";
|
|
7
|
+
/**
|
|
8
|
+
* 面遮罩图层辅助类。
|
|
9
|
+
*/
|
|
10
|
+
export default class PolygonMaskLayer {
|
|
11
|
+
static setOutLayer(map: Map, data: MapJSONData, options?: {
|
|
12
|
+
layerName?: string;
|
|
13
|
+
extent?: any;
|
|
14
|
+
fillColor?: string;
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
strokeColor?: string;
|
|
17
|
+
zIndex?: number;
|
|
18
|
+
}): VectorLayer<VectorSource<Feature<Geometry>>, Feature<Geometry>>;
|
|
19
|
+
static addMaskLayer(map: Map, data: any, options?: MaskLayerOptions): VectorLayer<VectorSource>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import Feature from "ol/Feature";
|
|
2
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
3
|
+
import { LinearRing } from "ol/geom";
|
|
4
|
+
import VectorLayer from "ol/layer/Vector";
|
|
5
|
+
import VectorSource from "ol/source/Vector";
|
|
6
|
+
import { Fill, Stroke, Style } from "ol/style";
|
|
7
|
+
import { fromExtent } from "ol/geom/Polygon";
|
|
8
|
+
import { ErrorHandler } from "../../utils/ErrorHandler";
|
|
9
|
+
import ValidationUtils from "../../utils/ValidationUtils";
|
|
10
|
+
import { ConfigManager } from "../map";
|
|
11
|
+
/**
|
|
12
|
+
* 面遮罩图层辅助类。
|
|
13
|
+
*/
|
|
14
|
+
export default class PolygonMaskLayer {
|
|
15
|
+
static setOutLayer(map, data, options) {
|
|
16
|
+
function getCoordsGroup(geom) {
|
|
17
|
+
let group = [];
|
|
18
|
+
const geomType = geom.getType();
|
|
19
|
+
if (geomType === 'LineString') {
|
|
20
|
+
group.push(geom.getCoordinates());
|
|
21
|
+
}
|
|
22
|
+
else if (geomType === 'MultiLineString' || geomType === 'Polygon') {
|
|
23
|
+
group = geom.getCoordinates();
|
|
24
|
+
}
|
|
25
|
+
else if (geomType === 'MultiPolygon') {
|
|
26
|
+
geom.getPolygons().forEach((poly) => {
|
|
27
|
+
group = group.concat(poly.getCoordinates());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
ErrorHandler.getInstance().warn('暂时不支持的类型');
|
|
32
|
+
}
|
|
33
|
+
return group;
|
|
34
|
+
}
|
|
35
|
+
function erase(geometries, view) {
|
|
36
|
+
let allParts = [];
|
|
37
|
+
geometries.forEach(geom => {
|
|
38
|
+
const parts = getCoordsGroup(geom);
|
|
39
|
+
if (parts && parts.length > 0) {
|
|
40
|
+
allParts = allParts.concat(parts);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (allParts.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const extent = view.getProjection().getExtent();
|
|
47
|
+
const polygonRing = fromExtent(extent);
|
|
48
|
+
allParts.forEach(item => {
|
|
49
|
+
polygonRing.appendLinearRing(new LinearRing(item));
|
|
50
|
+
});
|
|
51
|
+
return polygonRing;
|
|
52
|
+
}
|
|
53
|
+
const shadeStyle = new Style({
|
|
54
|
+
fill: new Fill({ color: options?.fillColor ?? 'rgba(0,27,59,0.8)' }),
|
|
55
|
+
stroke: new Stroke({
|
|
56
|
+
width: options?.strokeWidth ?? 1,
|
|
57
|
+
color: options?.strokeColor ?? 'rgba(0,27,59,0.8)'
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
const vtSource = new VectorSource();
|
|
61
|
+
const vtLayer = new VectorLayer({
|
|
62
|
+
source: vtSource,
|
|
63
|
+
style: shadeStyle,
|
|
64
|
+
zIndex: options?.zIndex ?? 12
|
|
65
|
+
});
|
|
66
|
+
vtLayer.set('layerName', options?.layerName ?? 'outLayer');
|
|
67
|
+
const features = new GeoJSON().readFeatures(data);
|
|
68
|
+
const geometries = [];
|
|
69
|
+
features.forEach(feature => {
|
|
70
|
+
const geometry = feature.getGeometry();
|
|
71
|
+
if (geometry) {
|
|
72
|
+
geometries.push(geometry);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (geometries.length > 0) {
|
|
76
|
+
const polygon = erase(geometries, map.getView());
|
|
77
|
+
if (polygon) {
|
|
78
|
+
vtSource.addFeature(new Feature({ geometry: polygon }));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
map.addLayer(vtLayer);
|
|
82
|
+
return vtLayer;
|
|
83
|
+
}
|
|
84
|
+
static addMaskLayer(map, data, options) {
|
|
85
|
+
ValidationUtils.validateMaskData(data);
|
|
86
|
+
const mergedOptions = {
|
|
87
|
+
...ConfigManager.DEFAULT_MASK_OPTIONS,
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
90
|
+
const features = new GeoJSON().readFeatures(data);
|
|
91
|
+
const maskLayer = new VectorLayer({
|
|
92
|
+
source: new VectorSource({ features }),
|
|
93
|
+
style: new Style({
|
|
94
|
+
fill: new Fill({ color: mergedOptions.fillColor }),
|
|
95
|
+
stroke: mergedOptions.strokeColor ? new Stroke({
|
|
96
|
+
color: mergedOptions.strokeColor,
|
|
97
|
+
width: mergedOptions.strokeWidth || 1
|
|
98
|
+
}) : undefined
|
|
99
|
+
}),
|
|
100
|
+
opacity: mergedOptions.opacity,
|
|
101
|
+
visible: mergedOptions.visible
|
|
102
|
+
});
|
|
103
|
+
maskLayer.set('layerName', mergedOptions.layerName);
|
|
104
|
+
map.addLayer(maskLayer);
|
|
105
|
+
return maskLayer;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Feature from "ol/Feature";
|
|
2
|
+
import type { FeatureColorUpdateOptions, PolygonOptions } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* 面图层样式工厂。
|
|
5
|
+
*/
|
|
6
|
+
export default class PolygonStyleFactory {
|
|
7
|
+
static getFeatureText(feature: Feature, options: PolygonOptions | FeatureColorUpdateOptions): string;
|
|
8
|
+
static createStyle(options: PolygonOptions): any;
|
|
9
|
+
static updateSingleFeatureColor(feature: Feature, colorObj?: {
|
|
10
|
+
[propName: string]: string;
|
|
11
|
+
}, options?: FeatureColorUpdateOptions): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Fill, Stroke, Style, Text } from "ol/style";
|
|
2
|
+
/**
|
|
3
|
+
* 面图层样式工厂。
|
|
4
|
+
*/
|
|
5
|
+
export default class PolygonStyleFactory {
|
|
6
|
+
static getFeatureText(feature, options) {
|
|
7
|
+
if (options.textCallBack) {
|
|
8
|
+
return options.textCallBack(feature) || '';
|
|
9
|
+
}
|
|
10
|
+
if (options.textKey) {
|
|
11
|
+
return feature.get(options.textKey) || '';
|
|
12
|
+
}
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
static createStyle(options) {
|
|
16
|
+
if (options.style) {
|
|
17
|
+
return options.style;
|
|
18
|
+
}
|
|
19
|
+
const withDefaultStroke = options.withDefaultStroke ?? true;
|
|
20
|
+
const withDefaultFill = options.withDefaultFill ?? true;
|
|
21
|
+
const strokeColor = options.strokeColor ?? (withDefaultStroke ? '#EBEEF5' : undefined);
|
|
22
|
+
const strokeWidth = options.strokeWidth ?? 2;
|
|
23
|
+
const staticFillColor = options.fillColor ?? (withDefaultFill ? 'rgba(255, 255, 255, 0)' : undefined);
|
|
24
|
+
const stroke = strokeColor ? new Stroke({
|
|
25
|
+
color: strokeColor,
|
|
26
|
+
width: strokeWidth,
|
|
27
|
+
lineDash: options.lineDash,
|
|
28
|
+
lineDashOffset: options.lineDashOffset
|
|
29
|
+
}) : undefined;
|
|
30
|
+
let baseStyle;
|
|
31
|
+
if (!options.fillColorCallBack) {
|
|
32
|
+
const fill = staticFillColor ? new Fill({ color: staticFillColor }) : undefined;
|
|
33
|
+
if (stroke || fill) {
|
|
34
|
+
baseStyle = new Style({ stroke, fill });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (baseStyle && !options.textVisible) {
|
|
38
|
+
return baseStyle;
|
|
39
|
+
}
|
|
40
|
+
return (feature) => {
|
|
41
|
+
const styles = [];
|
|
42
|
+
if (baseStyle) {
|
|
43
|
+
styles.push(baseStyle);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const fillColor = options.fillColorCallBack ? options.fillColorCallBack(feature) : staticFillColor;
|
|
47
|
+
const fill = fillColor ? new Fill({ color: fillColor }) : undefined;
|
|
48
|
+
if (stroke || fill) {
|
|
49
|
+
styles.push(new Style({ stroke, fill }));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (options.textVisible) {
|
|
53
|
+
const text = PolygonStyleFactory.getFeatureText(feature, options);
|
|
54
|
+
if (text) {
|
|
55
|
+
styles.push(new Style({
|
|
56
|
+
text: new Text({
|
|
57
|
+
text,
|
|
58
|
+
font: options.textFont,
|
|
59
|
+
fill: new Fill({ color: options.textFillColor }),
|
|
60
|
+
stroke: new Stroke({
|
|
61
|
+
color: options.textStrokeColor,
|
|
62
|
+
width: options.textStrokeWidth
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return styles;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
static updateSingleFeatureColor(feature, colorObj, options) {
|
|
72
|
+
const name = options?.textKey ? feature.get(options.textKey) : '';
|
|
73
|
+
const withDefaultStroke = options?.withDefaultStroke ?? true;
|
|
74
|
+
const withDefaultFill = options?.withDefaultFill ?? true;
|
|
75
|
+
const strokeColor = options?.strokeColor ?? (withDefaultStroke ? '#EBEEF5' : undefined);
|
|
76
|
+
const strokeWidth = options?.strokeWidth ?? 2;
|
|
77
|
+
const defaultFillColor = 'rgba(255, 255, 255, 0.3)';
|
|
78
|
+
const resolvedFillColor = options?.fillColor ?? (withDefaultFill ? defaultFillColor : undefined);
|
|
79
|
+
const newColor = colorObj?.[name] || resolvedFillColor;
|
|
80
|
+
const featureStyle = new Style({
|
|
81
|
+
stroke: strokeColor ? new Stroke({ color: strokeColor, width: strokeWidth }) : undefined,
|
|
82
|
+
fill: newColor ? new Fill({ color: newColor }) : undefined
|
|
83
|
+
});
|
|
84
|
+
if (options?.textVisible) {
|
|
85
|
+
const text = PolygonStyleFactory.getFeatureText(feature, options);
|
|
86
|
+
if (text) {
|
|
87
|
+
featureStyle.setText(new Text({
|
|
88
|
+
text,
|
|
89
|
+
font: options.textFont,
|
|
90
|
+
fill: new Fill({ color: options.textFillColor }),
|
|
91
|
+
stroke: new Stroke({
|
|
92
|
+
color: options.textStrokeColor,
|
|
93
|
+
width: options.textStrokeWidth
|
|
94
|
+
})
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
feature.setStyle(featureStyle);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Polygon } from './Polygon';
|
|
2
|
+
export { default as PolygonStyleFactory } from './PolygonStyleFactory';
|
|
3
|
+
export { default as PolygonMaskLayer } from './PolygonMaskLayer';
|
|
4
|
+
export { default as PolygonImageLayer } from './PolygonImageLayer';
|
|
5
|
+
export { default as PolygonHeatmapLayer } from './PolygonHeatmapLayer';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Polygon } from './Polygon';
|
|
2
|
+
export { default as PolygonStyleFactory } from './PolygonStyleFactory';
|
|
3
|
+
export { default as PolygonMaskLayer } from './PolygonMaskLayer';
|
|
4
|
+
export { default as PolygonImageLayer } from './PolygonImageLayer';
|
|
5
|
+
export { default as PolygonHeatmapLayer } from './PolygonHeatmapLayer';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import OlMap from "ol/Map";
|
|
2
2
|
import { FeatureLike } from "ol/Feature";
|
|
3
|
-
import {
|
|
4
|
-
import { SelectOptions, SelectMode, ProgrammaticSelectOptions } from "../types";
|
|
3
|
+
import { SelectOptions, SelectMode, ProgrammaticSelectOptions } from "../../types";
|
|
5
4
|
/**
|
|
6
5
|
* 要素选择处理器类
|
|
7
6
|
* 用于在地图上选择和高亮显示要素,支持单选、多选等多种选择模式
|
|
@@ -79,7 +78,7 @@ export default class SelectHandler {
|
|
|
79
78
|
private ensureMainInteraction;
|
|
80
79
|
isSelectEnabled(): boolean;
|
|
81
80
|
getCurrentMode(): SelectMode | undefined;
|
|
82
|
-
updateSelectStyle(selectStyle:
|
|
81
|
+
updateSelectStyle(selectStyle: SelectOptions['selectStyle']): this;
|
|
83
82
|
private fitToFeatures;
|
|
84
83
|
destroy(): void;
|
|
85
84
|
private getSelectCondition;
|
|
@@ -5,9 +5,9 @@ import VectorLayer from "ol/layer/Vector";
|
|
|
5
5
|
import { Style, Fill, Stroke, Circle as CircleStyle } from "ol/style";
|
|
6
6
|
import Collection from 'ol/Collection';
|
|
7
7
|
import { getUid } from "ol/util";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { ErrorHandler, MyOpenLayersError, ErrorType } from "
|
|
8
|
+
import EventManager from "../map/EventManager";
|
|
9
|
+
import ValidationUtils from "../../utils/ValidationUtils";
|
|
10
|
+
import { ErrorHandler, MyOpenLayersError, ErrorType } from "../../utils/ErrorHandler";
|
|
11
11
|
/**
|
|
12
12
|
* 要素选择处理器类
|
|
13
13
|
* 用于在地图上选择和高亮显示要素,支持单选、多选等多种选择模式
|
|
@@ -370,7 +370,7 @@ export default class SelectHandler {
|
|
|
370
370
|
const styleSource = this.currentSelectStyle;
|
|
371
371
|
if (styleSource) {
|
|
372
372
|
if (typeof styleSource === 'function') {
|
|
373
|
-
return styleSource(feature
|
|
373
|
+
return styleSource(feature);
|
|
374
374
|
}
|
|
375
375
|
return styleSource;
|
|
376
376
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SelectHandler } from './SelectHandler';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SelectHandler } from './SelectHandler';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Overlay from 'ol/Overlay';
|
|
2
|
-
import { VueTemplatePointState } from '
|
|
3
|
-
import { ErrorHandler, ErrorType } from '
|
|
4
|
-
import
|
|
5
|
-
import { ConfigManager } from '
|
|
2
|
+
import { VueTemplatePointState } from '../../types';
|
|
3
|
+
import { ErrorHandler, ErrorType } from '../../utils/ErrorHandler';
|
|
4
|
+
import ValidationUtils from '../../utils/ValidationUtils';
|
|
5
|
+
import { ConfigManager } from '../map';
|
|
6
6
|
// 动态导入Vue
|
|
7
7
|
let Vue = null;
|
|
8
8
|
let isVue3 = false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as VueTemplatePoint } from './VueTemplatePoint';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as VueTemplatePoint } from './VueTemplatePoint';
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { defineConfig } from 'vitepress'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
base: '/my-openlayer/',
|
|
5
|
-
title: "MyOpenLayer",
|
|
6
|
-
description: "基于 OpenLayers 的现代地图组件库",
|
|
7
|
-
lang: 'zh-CN',
|
|
8
|
-
themeConfig: {
|
|
9
|
-
nav: [
|
|
10
|
-
{ text: '首页', link: '/' },
|
|
11
|
-
{ text: '指南', link: '/MyOl' },
|
|
12
|
-
{ text: 'API', link: '/MyOl' },
|
|
13
|
-
{ text: 'GitHub', link: 'https://github.com/cuteyuchen/my-openlayer' }
|
|
14
|
-
],
|
|
15
|
-
|
|
16
|
-
sidebar: [
|
|
17
|
-
{
|
|
18
|
-
text: '核心类库',
|
|
19
|
-
items: [
|
|
20
|
-
{ text: 'MyOl 地图入口', link: '/MyOl' },
|
|
21
|
-
{ text: 'MapBaseLayers 底图管理', link: '/MapBaseLayers' },
|
|
22
|
-
{ text: 'ConfigManager 配置管理', link: '/ConfigManager' },
|
|
23
|
-
{ text: 'EventManager 事件管理', link: '/EventManager' },
|
|
24
|
-
{ text: 'ErrorHandler 错误处理', link: '/ErrorHandler' }
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
text: '要素操作',
|
|
29
|
-
items: [
|
|
30
|
-
{ text: 'Point 点要素', link: '/Point' },
|
|
31
|
-
{ text: 'Line 线要素', link: '/Line' },
|
|
32
|
-
{ text: 'Polygon 面要素', link: '/Polygon' },
|
|
33
|
-
{ text: 'VueTemplatePoint Vue点位', link: '/VueTemplatePoint' },
|
|
34
|
-
{ text: 'RiverLayerManager 河流图层', link: '/RiverLayerManager' }
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
text: '交互与工具',
|
|
39
|
-
items: [
|
|
40
|
-
{ text: 'SelectHandler 要素选择', link: '/SelectHandler' },
|
|
41
|
-
{ text: 'MeasureHandler 测量工具', link: '/MeasureHandler' },
|
|
42
|
-
{ text: 'MapTools 地图工具', link: '/MapTools' },
|
|
43
|
-
{ text: 'ValidationUtils 验证工具', link: '/ValidationUtils' }
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
|
|
48
|
-
socialLinks: [
|
|
49
|
-
{ icon: 'github', link: 'https://github.com/cuteyuchen/my-openlayer' }
|
|
50
|
-
],
|
|
51
|
-
|
|
52
|
-
footer: {
|
|
53
|
-
message: 'Released under the MIT License.',
|
|
54
|
-
copyright: 'Copyright © 2024-present'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
})
|
|
1
|
+
import { defineConfig } from 'vitepress'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
base: '/my-openlayer/',
|
|
5
|
+
title: "MyOpenLayer",
|
|
6
|
+
description: "基于 OpenLayers 的现代地图组件库",
|
|
7
|
+
lang: 'zh-CN',
|
|
8
|
+
themeConfig: {
|
|
9
|
+
nav: [
|
|
10
|
+
{ text: '首页', link: '/' },
|
|
11
|
+
{ text: '指南', link: '/MyOl' },
|
|
12
|
+
{ text: 'API', link: '/MyOl' },
|
|
13
|
+
{ text: 'GitHub', link: 'https://github.com/cuteyuchen/my-openlayer' }
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
sidebar: [
|
|
17
|
+
{
|
|
18
|
+
text: '核心类库',
|
|
19
|
+
items: [
|
|
20
|
+
{ text: 'MyOl 地图入口', link: '/MyOl' },
|
|
21
|
+
{ text: 'MapBaseLayers 底图管理', link: '/MapBaseLayers' },
|
|
22
|
+
{ text: 'ConfigManager 配置管理', link: '/ConfigManager' },
|
|
23
|
+
{ text: 'EventManager 事件管理', link: '/EventManager' },
|
|
24
|
+
{ text: 'ErrorHandler 错误处理', link: '/ErrorHandler' }
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
text: '要素操作',
|
|
29
|
+
items: [
|
|
30
|
+
{ text: 'Point 点要素', link: '/Point' },
|
|
31
|
+
{ text: 'Line 线要素', link: '/Line' },
|
|
32
|
+
{ text: 'Polygon 面要素', link: '/Polygon' },
|
|
33
|
+
{ text: 'VueTemplatePoint Vue点位', link: '/VueTemplatePoint' },
|
|
34
|
+
{ text: 'RiverLayerManager 河流图层', link: '/RiverLayerManager' }
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
text: '交互与工具',
|
|
39
|
+
items: [
|
|
40
|
+
{ text: 'SelectHandler 要素选择', link: '/SelectHandler' },
|
|
41
|
+
{ text: 'MeasureHandler 测量工具', link: '/MeasureHandler' },
|
|
42
|
+
{ text: 'MapTools 地图工具', link: '/MapTools' },
|
|
43
|
+
{ text: 'ValidationUtils 验证工具', link: '/ValidationUtils' }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
socialLinks: [
|
|
49
|
+
{ icon: 'github', link: 'https://github.com/cuteyuchen/my-openlayer' }
|
|
50
|
+
],
|
|
51
|
+
|
|
52
|
+
footer: {
|
|
53
|
+
message: 'Released under the MIT License.',
|
|
54
|
+
copyright: 'Copyright © 2024-present'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})
|
package/docs/ConfigManager.md
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
# ConfigManager 配置管理
|
|
2
|
-
|
|
3
|
-
`ConfigManager` 类用于统一管理地图组件的默认配置和常量。它提供了一系列静态只读属性,确保整个应用中使用一致的配置默认值。
|
|
4
|
-
|
|
5
|
-
## 导入
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { ConfigManager } from 'my-openlayer';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 静态属性
|
|
12
|
-
|
|
13
|
-
`ConfigManager` 包含以下类别的默认配置:
|
|
14
|
-
|
|
15
|
-
### 点位配置 (Point Options)
|
|
16
|
-
|
|
17
|
-
| 属性名 | 类型 | 描述 | 默认值 |
|
|
18
|
-
| :--- | :--- | :--- | :--- |
|
|
19
|
-
| `DEFAULT_POINT_OPTIONS` | `object` | 默认点位基础配置 | `{ visible: true, zIndex: 21 }` |
|
|
20
|
-
| `DEFAULT_POINT_TEXT_OPTIONS` | `object` | 默认点位文本配置 | `{ textFont: '12px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#000', textStrokeWidth: 3, textOffsetY: 20 }` |
|
|
21
|
-
| `DEFAULT_POINT_ICON_SCALE` | `number` | 默认图标缩放比例 | `1` |
|
|
22
|
-
| `DEFAULT_CLUSTER_OPTIONS` | `object` | 默认聚合配置 | `{ distance: 40, minDistance: 0, zIndex: 21 }` |
|
|
23
|
-
| `DEFAULT_DOM_POINT_OVERLAY_OPTIONS` | `object` | 默认 DOM 点覆盖物配置 | `{ positioning: 'center-center', stopEvent: false }` |
|
|
24
|
-
|
|
25
|
-
### 线配置 (Line Options)
|
|
26
|
-
|
|
27
|
-
| 属性名 | 类型 | 描述 | 默认值 |
|
|
28
|
-
| :--- | :--- | :--- | :--- |
|
|
29
|
-
| `DEFAULT_LINE_OPTIONS` | `object` | 默认线样式配置 | `{ type: 'line', strokeColor: 'rgba(3, 122, 255, 1)', strokeWidth: 2, visible: true, layerName: 'lineLayer', zIndex: 15 }` |
|
|
30
|
-
|
|
31
|
-
### 面配置 (Polygon Options)
|
|
32
|
-
|
|
33
|
-
| 属性名 | 类型 | 描述 | 默认值 |
|
|
34
|
-
| :--- | :--- | :--- | :--- |
|
|
35
|
-
| `DEFAULT_POLYGON_OPTIONS` | `object` | 默认面样式配置 | `{ zIndex: 11, visible: true, textFont: '14px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#409EFF', textStrokeWidth: 2 }` |
|
|
36
|
-
| `DEFAULT_POLYGON_COLOR_MAP` | `object` | 默认面颜色映射 (用于分级渲染) | `{ '0': 'rgba(255, 0, 0, 0.6)', '1': 'rgba(245, 154, 35, 0.6)', ... }` |
|
|
37
|
-
|
|
38
|
-
## 使用示例
|
|
39
|
-
|
|
40
|
-
### 获取默认配置
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { ConfigManager } from 'my-openlayer';
|
|
44
|
-
|
|
45
|
-
// 获取默认点位配置
|
|
46
|
-
const pointOptions = {
|
|
47
|
-
...ConfigManager.DEFAULT_POINT_OPTIONS,
|
|
48
|
-
...ConfigManager.DEFAULT_POINT_TEXT_OPTIONS
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// 获取默认线配置
|
|
52
|
-
const lineOptions = ConfigManager.DEFAULT_LINE_OPTIONS;
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 在自定义组件中使用
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { ConfigManager } from 'my-openlayer';
|
|
59
|
-
|
|
60
|
-
class MyComponent {
|
|
61
|
-
private options: any;
|
|
62
|
-
|
|
63
|
-
constructor(options: any) {
|
|
64
|
-
// 合并用户配置和默认配置
|
|
65
|
-
this.options = {
|
|
66
|
-
...ConfigManager.DEFAULT_POINT_OPTIONS,
|
|
67
|
-
...options
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
```
|
|
1
|
+
# ConfigManager 配置管理
|
|
2
|
+
|
|
3
|
+
`ConfigManager` 类用于统一管理地图组件的默认配置和常量。它提供了一系列静态只读属性,确保整个应用中使用一致的配置默认值。
|
|
4
|
+
|
|
5
|
+
## 导入
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ConfigManager } from 'my-openlayer';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 静态属性
|
|
12
|
+
|
|
13
|
+
`ConfigManager` 包含以下类别的默认配置:
|
|
14
|
+
|
|
15
|
+
### 点位配置 (Point Options)
|
|
16
|
+
|
|
17
|
+
| 属性名 | 类型 | 描述 | 默认值 |
|
|
18
|
+
| :--- | :--- | :--- | :--- |
|
|
19
|
+
| `DEFAULT_POINT_OPTIONS` | `object` | 默认点位基础配置 | `{ visible: true, zIndex: 21 }` |
|
|
20
|
+
| `DEFAULT_POINT_TEXT_OPTIONS` | `object` | 默认点位文本配置 | `{ textFont: '12px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#000', textStrokeWidth: 3, textOffsetY: 20 }` |
|
|
21
|
+
| `DEFAULT_POINT_ICON_SCALE` | `number` | 默认图标缩放比例 | `1` |
|
|
22
|
+
| `DEFAULT_CLUSTER_OPTIONS` | `object` | 默认聚合配置 | `{ distance: 40, minDistance: 0, zIndex: 21 }` |
|
|
23
|
+
| `DEFAULT_DOM_POINT_OVERLAY_OPTIONS` | `object` | 默认 DOM 点覆盖物配置 | `{ positioning: 'center-center', stopEvent: false }` |
|
|
24
|
+
|
|
25
|
+
### 线配置 (Line Options)
|
|
26
|
+
|
|
27
|
+
| 属性名 | 类型 | 描述 | 默认值 |
|
|
28
|
+
| :--- | :--- | :--- | :--- |
|
|
29
|
+
| `DEFAULT_LINE_OPTIONS` | `object` | 默认线样式配置 | `{ type: 'line', strokeColor: 'rgba(3, 122, 255, 1)', strokeWidth: 2, visible: true, layerName: 'lineLayer', zIndex: 15 }` |
|
|
30
|
+
|
|
31
|
+
### 面配置 (Polygon Options)
|
|
32
|
+
|
|
33
|
+
| 属性名 | 类型 | 描述 | 默认值 |
|
|
34
|
+
| :--- | :--- | :--- | :--- |
|
|
35
|
+
| `DEFAULT_POLYGON_OPTIONS` | `object` | 默认面样式配置 | `{ zIndex: 11, visible: true, textFont: '14px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#409EFF', textStrokeWidth: 2 }` |
|
|
36
|
+
| `DEFAULT_POLYGON_COLOR_MAP` | `object` | 默认面颜色映射 (用于分级渲染) | `{ '0': 'rgba(255, 0, 0, 0.6)', '1': 'rgba(245, 154, 35, 0.6)', ... }` |
|
|
37
|
+
|
|
38
|
+
## 使用示例
|
|
39
|
+
|
|
40
|
+
### 获取默认配置
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { ConfigManager } from 'my-openlayer';
|
|
44
|
+
|
|
45
|
+
// 获取默认点位配置
|
|
46
|
+
const pointOptions = {
|
|
47
|
+
...ConfigManager.DEFAULT_POINT_OPTIONS,
|
|
48
|
+
...ConfigManager.DEFAULT_POINT_TEXT_OPTIONS
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// 获取默认线配置
|
|
52
|
+
const lineOptions = ConfigManager.DEFAULT_LINE_OPTIONS;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 在自定义组件中使用
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { ConfigManager } from 'my-openlayer';
|
|
59
|
+
|
|
60
|
+
class MyComponent {
|
|
61
|
+
private options: any;
|
|
62
|
+
|
|
63
|
+
constructor(options: any) {
|
|
64
|
+
// 合并用户配置和默认配置
|
|
65
|
+
this.options = {
|
|
66
|
+
...ConfigManager.DEFAULT_POINT_OPTIONS,
|
|
67
|
+
...options
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|