my-openlayer 3.1.0 → 3.1.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.1.1] - 2026-06-09
4
+
5
+ ### Bug Fixes
6
+
7
+ - **GeoJSON:** 修复 `addGeoJSON` 传入字符串 `layerName` 时被追加 `groupKey` 和 `geometryType` 的问题;字符串现在作为最终图层名原样使用。
8
+ - **GeoJSON:** 调整混合点线面渲染顺序,避免字符串 `layerName` 同名时面图层清理逻辑误删本次创建的点/线图层。
9
+
10
+ ### Tests
11
+
12
+ - 更新 `addGeoJSON` 图层命名回归测试,覆盖字符串 `layerName` 原样使用且混合图层完整保留。
13
+
3
14
  ## [3.1.0] - 2026-06-09
4
15
 
5
16
  ### Features
@@ -18,12 +18,12 @@ function resolveGeoJSONLayerName(layerName, groupKey, geometryType, datasetKey,
18
18
  if (typeof layerName === 'function') {
19
19
  return layerName({ datasetKey, groupKey, geometryType, index });
20
20
  }
21
- // 确定 base 名称
22
- let base;
23
21
  if (typeof layerName === 'string') {
24
- base = layerName;
22
+ return layerName;
25
23
  }
26
- else if (Array.isArray(layerName)) {
24
+ // 确定 base 名称
25
+ let base;
26
+ if (Array.isArray(layerName)) {
27
27
  base = layerName[Number(datasetKey)] ?? `${layerName[0] ?? 'geojson'}_${datasetKey}`;
28
28
  }
29
29
  else {
@@ -200,13 +200,13 @@ export function renderGeoJSON(data, options, deps) {
200
200
  const pointDatasetKey = pointFeatures[0]?._datasetKey ?? 'default';
201
201
  const lineDatasetKey = lineFeatures[0]?._datasetKey ?? 'default';
202
202
  const polygonDatasetKey = polygonFeatures[0]?._datasetKey ?? 'default';
203
- // 点图层
204
- if (pointFeatures.length > 0) {
205
- const result = createPointLayerHandle(pointFeatures, options, groupKey, pointDatasetKey, singleGroup, deps.getPoint());
206
- pointHandle = result.handle;
207
- if (pointHandle) {
208
- groupAllHandles.push(pointHandle);
209
- allHandles.push(pointHandle);
203
+ // 面图层会清理同名旧图层;当 layerName 是字符串时点线面同名,
204
+ // 因此先创建面图层,避免它误删本次刚创建的点/线图层。
205
+ if (polygonFeatures.length > 0) {
206
+ polygonHandle = createPolygonHandle(polygonFeatures, options, groupKey, polygonDatasetKey, singleGroup, deps.getPolygon());
207
+ if (polygonHandle) {
208
+ groupAllHandles.push(polygonHandle);
209
+ allHandles.push(polygonHandle);
210
210
  }
211
211
  }
212
212
  // 线图层
@@ -217,12 +217,13 @@ export function renderGeoJSON(data, options, deps) {
217
217
  allHandles.push(lineHandle);
218
218
  }
219
219
  }
220
- // 面图层
221
- if (polygonFeatures.length > 0) {
222
- polygonHandle = createPolygonHandle(polygonFeatures, options, groupKey, polygonDatasetKey, singleGroup, deps.getPolygon());
223
- if (polygonHandle) {
224
- groupAllHandles.push(polygonHandle);
225
- allHandles.push(polygonHandle);
220
+ // 点图层
221
+ if (pointFeatures.length > 0) {
222
+ const result = createPointLayerHandle(pointFeatures, options, groupKey, pointDatasetKey, singleGroup, deps.getPoint());
223
+ pointHandle = result.handle;
224
+ if (pointHandle) {
225
+ groupAllHandles.push(pointHandle);
226
+ allHandles.push(pointHandle);
226
227
  }
227
228
  }
228
229
  /** *********************组装分组句柄*********************/
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "my-openlayer",
3
3
  "private": false,
4
- "version": "3.1.0",
4
+ "version": "3.1.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "index.js",