my-openlayer 1.0.5 → 1.0.6
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/core/Point.d.ts +1 -1
- package/core/Point.js +6 -6
- package/core/Polygon.js +3 -3
- package/package.json +1 -1
- package/types.d.ts +7 -7
package/core/Point.d.ts
CHANGED
package/core/Point.js
CHANGED
|
@@ -61,8 +61,8 @@ export default class Point {
|
|
|
61
61
|
*/
|
|
62
62
|
createPointStyle(options, item) {
|
|
63
63
|
const style = {};
|
|
64
|
-
if (options.
|
|
65
|
-
style.text = this.createTextStyle(options, item[options.
|
|
64
|
+
if (options.textKey && item) {
|
|
65
|
+
style.text = this.createTextStyle(options, item[options.textKey]);
|
|
66
66
|
}
|
|
67
67
|
if (options.img) {
|
|
68
68
|
style.image = this.createIconStyle(options);
|
|
@@ -78,7 +78,7 @@ export default class Point {
|
|
|
78
78
|
*/
|
|
79
79
|
createClusterStyle(options, name) {
|
|
80
80
|
const style = {};
|
|
81
|
-
if (options.
|
|
81
|
+
if (options.textKey) {
|
|
82
82
|
style.text = this.createTextStyle(options, name);
|
|
83
83
|
}
|
|
84
84
|
if (options.img) {
|
|
@@ -101,7 +101,7 @@ export default class Point {
|
|
|
101
101
|
* @param pointData
|
|
102
102
|
* @param type
|
|
103
103
|
* @param options {
|
|
104
|
-
*
|
|
104
|
+
* textKey: String 数据中的文本的key
|
|
105
105
|
* img: String 图标
|
|
106
106
|
* }
|
|
107
107
|
*/
|
|
@@ -143,7 +143,7 @@ export default class Point {
|
|
|
143
143
|
}
|
|
144
144
|
const pointFeature = new Feature({
|
|
145
145
|
geometry: new olPoint([item.lgtd, item.lttd]),
|
|
146
|
-
name: options.
|
|
146
|
+
name: options.textKey ? item[options.textKey] : '',
|
|
147
147
|
});
|
|
148
148
|
pointFeatureList.push(pointFeature);
|
|
149
149
|
});
|
|
@@ -159,7 +159,7 @@ export default class Point {
|
|
|
159
159
|
layerName: options.layerName,
|
|
160
160
|
source: clusterSource,
|
|
161
161
|
style: (feature) => {
|
|
162
|
-
const name = feature.get('features')[0].get(options.
|
|
162
|
+
const name = feature.get('features')[0].get(options.textKey);
|
|
163
163
|
return this.createClusterStyle(options, name);
|
|
164
164
|
},
|
|
165
165
|
zIndex: options.zIndex || 21,
|
package/core/Polygon.js
CHANGED
|
@@ -159,8 +159,8 @@ export default class Polygon {
|
|
|
159
159
|
if (options.textCallBack) {
|
|
160
160
|
return options.textCallBack(feature) || '';
|
|
161
161
|
}
|
|
162
|
-
if (options.
|
|
163
|
-
return feature.get(options.
|
|
162
|
+
if (options.textKey) {
|
|
163
|
+
return feature.get(options.textKey) || '';
|
|
164
164
|
}
|
|
165
165
|
return '';
|
|
166
166
|
}
|
|
@@ -217,7 +217,7 @@ export default class Polygon {
|
|
|
217
217
|
* @param options 配置选项
|
|
218
218
|
*/
|
|
219
219
|
updateSingleFeatureColor(feature, colorObj, options) {
|
|
220
|
-
const name = options?.
|
|
220
|
+
const name = options?.textKey ? feature.get(options.textKey) : '';
|
|
221
221
|
const newColor = colorObj?.[name] || options?.fillColor;
|
|
222
222
|
const featureStyle = new Style({
|
|
223
223
|
stroke: new Stroke({
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -124,8 +124,8 @@ export interface TextOptions {
|
|
|
124
124
|
* 点位选项接口 - 点位图层专用配置
|
|
125
125
|
*/
|
|
126
126
|
export interface PointOptions extends BaseOptions, StyleOptions, TextOptions {
|
|
127
|
-
/**
|
|
128
|
-
|
|
127
|
+
/** 文本字段键 */
|
|
128
|
+
textKey?: string;
|
|
129
129
|
/** 图标图片 */
|
|
130
130
|
img?: string;
|
|
131
131
|
/** 图标缩放比例 */
|
|
@@ -144,8 +144,8 @@ export interface LineOptions extends BaseOptions, StyleOptions, TextOptions {
|
|
|
144
144
|
* 多边形选项接口 - 多边形图层专用配置
|
|
145
145
|
*/
|
|
146
146
|
export interface PolygonOptions extends BaseOptions, StyleOptions, TextOptions {
|
|
147
|
-
/**
|
|
148
|
-
|
|
147
|
+
/** 文本字段键 */
|
|
148
|
+
textKey?: string;
|
|
149
149
|
/** 是否为蒙版 */
|
|
150
150
|
mask?: boolean;
|
|
151
151
|
}
|
|
@@ -154,7 +154,7 @@ export interface PolygonOptions extends BaseOptions, StyleOptions, TextOptions {
|
|
|
154
154
|
* @deprecated 请使用具体的选项接口:PointOptions, LineOptions, PolygonOptions
|
|
155
155
|
*/
|
|
156
156
|
export type OptionsType = BaseOptions & StyleOptions & TextOptions & {
|
|
157
|
-
|
|
157
|
+
textKey?: string;
|
|
158
158
|
img?: string;
|
|
159
159
|
scale?: number;
|
|
160
160
|
iconColor?: string;
|
|
@@ -191,8 +191,8 @@ export interface ColorMap {
|
|
|
191
191
|
* 要素颜色更新选项接口
|
|
192
192
|
*/
|
|
193
193
|
export interface FeatureColorUpdateOptions extends BaseOptions, StyleOptions, TextOptions {
|
|
194
|
-
/**
|
|
195
|
-
|
|
194
|
+
/** 文本字段键 */
|
|
195
|
+
textKey?: string;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* 点位数据接口
|