Skip to content

Commit ad304ac

Browse files
committed
【fix】修复矢量瓦片更新样式时传值不全时样式丢失的问题 修复插件设计后不能调试的问题
1 parent 5e94d4e commit ad304ac

File tree

8 files changed

+664
-971
lines changed

8 files changed

+664
-971
lines changed

build/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ if (product) {
1313
const configBase = require(`./webpack.config.base.js`);
1414
const entry = [`./src/${product}/index.js`];
1515
const filename= product === 'classic' ? `iclient-classic` : `iclient-${product}`;
16-
config.output.filename = `${filename}-es6.min.js`
16+
config.output.filename = `${filename}-es6.min.js`;
17+
config.output.path = path.resolve(`${__dirname}/../dist/${product}`);
1718
if (['leaflet', 'openlayers'].includes(product)) {
1819
entry.push(`./src/${product}/css/index.js`);
1920
config.plugins = configBase.plugins(product, `${filename}.min`);

dist/openlayers/iclient-openlayers-es6.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90912,21 +90912,26 @@ class MapboxStyles_MapboxStyles extends external_ol_default.a.Observable {
9091290912
layerStyles = [layerStyles];
9091390913
}
9091490914
const layerObj = {};
90915-
for (const item in layerStyles) {
90916-
const layerStyle = layerStyles[item];
90915+
layerStyles.forEach(layerStyle => {
9091790916
layerObj[layerStyle.id] = layerStyle;
90918-
}
90917+
});
9091990918
let count = 0;
9092090919
for (const key in this._mbStyle.layers) {
9092190920
const oldLayerStyle = this._mbStyle.layers[key];
9092290921
if (count >= layerStyles.length) {
9092390922
break;
9092490923
}
90925-
const newLayerStyle = layerObj[oldLayerStyle.id];
90926-
if (!newLayerStyle) {
90924+
if (!layerObj[oldLayerStyle.id]) {
9092790925
continue;
9092890926
}
90929-
Util_Util.extend(oldLayerStyle, newLayerStyle);
90927+
const newLayerStyle = JSON.parse(JSON.stringify(layerObj[oldLayerStyle.id]));
90928+
if(newLayerStyle.paint){
90929+
newLayerStyle.paint = Object.assign({},oldLayerStyle.paint,newLayerStyle.paint);
90930+
}
90931+
if(newLayerStyle.layout){
90932+
newLayerStyle.layout = Object.assign({},oldLayerStyle.layout,newLayerStyle.layout);
90933+
}
90934+
Object.assign(oldLayerStyle,newLayerStyle);
9093090935
count++;
9093190936
}
9093290937
this._createStyleFunction();
@@ -94523,6 +94528,8 @@ external_ol_default.a.supermap.TrafficTransferAnalystService = TrafficTransferAn
9452394528
/* concated harmony reexport GeoFeature */__webpack_require__.d(__webpack_exports__, "GeoFeature", function() { return GeoFeature_GeoFeature; });
9452494529
/* concated harmony reexport Theme */__webpack_require__.d(__webpack_exports__, "Theme", function() { return theme_Theme_Theme; });
9452594530
/* concated harmony reexport ThemeFeature */__webpack_require__.d(__webpack_exports__, "ThemeFeature", function() { return ThemeFeature_ThemeFeature; });
94531+
/* concated harmony reexport VectorTileStyles */__webpack_require__.d(__webpack_exports__, "VectorTileStyles", function() { return VectorTileStyles_VectorTileStyles; });
94532+
/* concated harmony reexport MapboxStyles */__webpack_require__.d(__webpack_exports__, "MapboxStyles", function() { return MapboxStyles_MapboxStyles; });
9452694533
/* concated harmony reexport pointStyle */__webpack_require__.d(__webpack_exports__, "pointStyle", function() { return DeafultCanvasStyle_pointStyle; });
9452794534
/* concated harmony reexport lineStyle */__webpack_require__.d(__webpack_exports__, "lineStyle", function() { return DeafultCanvasStyle_lineStyle; });
9452894535
/* concated harmony reexport polygonStyle */__webpack_require__.d(__webpack_exports__, "polygonStyle", function() { return DeafultCanvasStyle_polygonStyle; });
@@ -94531,8 +94538,6 @@ external_ol_default.a.supermap.TrafficTransferAnalystService = TrafficTransferAn
9453194538
/* concated harmony reexport lineMap */__webpack_require__.d(__webpack_exports__, "lineMap", function() { return lineMap; });
9453294539
/* concated harmony reexport polygonMap */__webpack_require__.d(__webpack_exports__, "polygonMap", function() { return polygonMap; });
9453394540
/* concated harmony reexport StyleMap */__webpack_require__.d(__webpack_exports__, "StyleMap", function() { return StyleMap; });
94534-
/* concated harmony reexport VectorTileStyles */__webpack_require__.d(__webpack_exports__, "VectorTileStyles", function() { return VectorTileStyles_VectorTileStyles; });
94535-
/* concated harmony reexport MapboxStyles */__webpack_require__.d(__webpack_exports__, "MapboxStyles", function() { return MapboxStyles_MapboxStyles; });
9453694541
/* concated harmony reexport AddressMatchService */__webpack_require__.d(__webpack_exports__, "AddressMatchService", function() { return services_AddressMatchService_AddressMatchService; });
9453794542
/* concated harmony reexport ChartService */__webpack_require__.d(__webpack_exports__, "ChartService", function() { return ChartService_ChartService; });
9453894543
/* concated harmony reexport DataFlowService */__webpack_require__.d(__webpack_exports__, "DataFlowService", function() { return services_DataFlowService_DataFlowService; });

dist/openlayers/iclient-openlayers-es6.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/openlayers/iclient-openlayers.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105620,12 +105620,9 @@ function (_ol$Observable) {
105620105620
}
105621105621

105622105622
var layerObj = {};
105623-
105624-
for (var item in layerStyles) {
105625-
var layerStyle = layerStyles[item];
105623+
layerStyles.forEach(function (layerStyle) {
105626105624
layerObj[layerStyle.id] = layerStyle;
105627-
}
105628-
105625+
});
105629105626
var count = 0;
105630105627

105631105628
for (var key in this._mbStyle.layers) {
@@ -105635,13 +105632,21 @@ function (_ol$Observable) {
105635105632
break;
105636105633
}
105637105634

105638-
var newLayerStyle = layerObj[oldLayerStyle.id];
105639-
105640-
if (!newLayerStyle) {
105635+
if (!layerObj[oldLayerStyle.id]) {
105641105636
continue;
105642105637
}
105643105638

105644-
Util_Util.extend(oldLayerStyle, newLayerStyle);
105639+
var newLayerStyle = JSON.parse(JSON.stringify(layerObj[oldLayerStyle.id]));
105640+
105641+
if (newLayerStyle.paint) {
105642+
newLayerStyle.paint = Object.assign({}, oldLayerStyle.paint, newLayerStyle.paint);
105643+
}
105644+
105645+
if (newLayerStyle.layout) {
105646+
newLayerStyle.layout = Object.assign({}, oldLayerStyle.layout, newLayerStyle.layout);
105647+
}
105648+
105649+
Object.assign(oldLayerStyle, newLayerStyle);
105645105650
count++;
105646105651
}
105647105652

@@ -109959,6 +109964,8 @@ external_ol_default.a.supermap.TrafficTransferAnalystService = TrafficTransferAn
109959109964
/* concated harmony reexport GeoFeature */__webpack_require__.d(__webpack_exports__, "GeoFeature", function() { return GeoFeature_GeoFeature; });
109960109965
/* concated harmony reexport Theme */__webpack_require__.d(__webpack_exports__, "Theme", function() { return theme_Theme_Theme; });
109961109966
/* concated harmony reexport ThemeFeature */__webpack_require__.d(__webpack_exports__, "ThemeFeature", function() { return ThemeFeature_ThemeFeature; });
109967+
/* concated harmony reexport VectorTileStyles */__webpack_require__.d(__webpack_exports__, "VectorTileStyles", function() { return VectorTileStyles_VectorTileStyles; });
109968+
/* concated harmony reexport MapboxStyles */__webpack_require__.d(__webpack_exports__, "MapboxStyles", function() { return MapboxStyles_MapboxStyles; });
109962109969
/* concated harmony reexport pointStyle */__webpack_require__.d(__webpack_exports__, "pointStyle", function() { return DeafultCanvasStyle_pointStyle; });
109963109970
/* concated harmony reexport lineStyle */__webpack_require__.d(__webpack_exports__, "lineStyle", function() { return DeafultCanvasStyle_lineStyle; });
109964109971
/* concated harmony reexport polygonStyle */__webpack_require__.d(__webpack_exports__, "polygonStyle", function() { return DeafultCanvasStyle_polygonStyle; });
@@ -109967,8 +109974,6 @@ external_ol_default.a.supermap.TrafficTransferAnalystService = TrafficTransferAn
109967109974
/* concated harmony reexport lineMap */__webpack_require__.d(__webpack_exports__, "lineMap", function() { return lineMap; });
109968109975
/* concated harmony reexport polygonMap */__webpack_require__.d(__webpack_exports__, "polygonMap", function() { return polygonMap; });
109969109976
/* concated harmony reexport StyleMap */__webpack_require__.d(__webpack_exports__, "StyleMap", function() { return StyleMap; });
109970-
/* concated harmony reexport VectorTileStyles */__webpack_require__.d(__webpack_exports__, "VectorTileStyles", function() { return VectorTileStyles_VectorTileStyles; });
109971-
/* concated harmony reexport MapboxStyles */__webpack_require__.d(__webpack_exports__, "MapboxStyles", function() { return MapboxStyles_MapboxStyles; });
109972109977
/* concated harmony reexport AddressMatchService */__webpack_require__.d(__webpack_exports__, "AddressMatchService", function() { return services_AddressMatchService_AddressMatchService; });
109973109978
/* concated harmony reexport ChartService */__webpack_require__.d(__webpack_exports__, "ChartService", function() { return ChartService_ChartService; });
109974109979
/* concated harmony reexport DataFlowService */__webpack_require__.d(__webpack_exports__, "DataFlowService", function() { return services_DataFlowService_DataFlowService; });

dist/openlayers/iclient-openlayers.min.js

Lines changed: 595 additions & 925 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/overlay/vectortile/MapboxStyles.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import ol from "openlayers";
5-
import { FetchRequest, CommonUtil } from "@supermap/iclient-common";
5+
import { FetchRequest } from "@supermap/iclient-common";
66
import { olExtends } from "./olExtends";
77
import remove from "lodash.remove";
88

@@ -196,21 +196,26 @@ export class MapboxStyles extends ol.Observable {
196196
layerStyles = [layerStyles];
197197
}
198198
const layerObj = {};
199-
for (const item in layerStyles) {
200-
const layerStyle = layerStyles[item];
199+
layerStyles.forEach(layerStyle => {
201200
layerObj[layerStyle.id] = layerStyle;
202-
}
201+
});
203202
let count = 0;
204203
for (const key in this._mbStyle.layers) {
205204
const oldLayerStyle = this._mbStyle.layers[key];
206205
if (count >= layerStyles.length) {
207206
break;
208207
}
209-
const newLayerStyle = layerObj[oldLayerStyle.id];
210-
if (!newLayerStyle) {
208+
if (!layerObj[oldLayerStyle.id]) {
211209
continue;
212210
}
213-
CommonUtil.extend(oldLayerStyle, newLayerStyle);
211+
const newLayerStyle = JSON.parse(JSON.stringify(layerObj[oldLayerStyle.id]));
212+
if(newLayerStyle.paint){
213+
newLayerStyle.paint = Object.assign({},oldLayerStyle.paint,newLayerStyle.paint);
214+
}
215+
if(newLayerStyle.layout){
216+
newLayerStyle.layout = Object.assign({},oldLayerStyle.layout,newLayerStyle.layout);
217+
}
218+
Object.assign(oldLayerStyle,newLayerStyle);
214219
count++;
215220
}
216221
this._createStyleFunction();

test/openlayers/overlay/vectortile/MapboxStylesSpec.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ describe("openlayers_MapboxStyles", () => {
7575
});
7676
const defaultColor = [249, 224, 219, 0.9];
7777
const highlightColor = [255, 0, 0, 1];
78-
const matchColor = function(style, expectColor) {
79-
expect(style.getFill().getColor()).not.toBeNull();
80-
const color = ol.color.asArray(style.getFill().getColor());
78+
const matchFillColor = function(style, expectColor) {
79+
matchColor(style.getFill().getColor(),expectColor);
80+
};
81+
const matchColor = function(sourceColor, expectColor) {
82+
expect(sourceColor).not.toBeNull();
83+
const color = ol.color.asArray(sourceColor);
8184
expectColor[0] && expect(color[0]).toBeCloseTo(expectColor[0]);
8285
expectColor[1] && expect(color[1]).toBeCloseTo(expectColor[1]);
8386
expectColor[2] && expect(color[2]).toBeCloseTo(expectColor[2]);
@@ -98,7 +101,8 @@ describe("openlayers_MapboxStyles", () => {
98101
mapboxStyles.on("styleloaded", () => {
99102
var style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
100103
expect(style).not.toBeNull();
101-
matchColor(style[0],defaultColor);
104+
matchFillColor(style[0],defaultColor);
105+
matchColor(style[1].getStroke().getColor(),defaultColor)
102106
mapboxStyles.updateStyles({
103107
paint: {
104108
"fill-color": "rgba(249,0,0,0.90)"
@@ -108,11 +112,13 @@ describe("openlayers_MapboxStyles", () => {
108112
});
109113
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758 / 2);
110114
expect(style).not.toBeNull();
111-
matchColor(style[0],[249,0,0,0.9]);
115+
expect(style.length).toBe(2);
116+
matchFillColor(style[0],[249,0,0,0.9]);
117+
matchColor(style[1].getStroke().getColor(),defaultColor)
112118
mapboxStyles.setSelectedId(1, "Military_R@California");
113119
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
114120
expect(style).not.toBeNull();
115-
matchColor(style[0],highlightColor);
121+
matchFillColor(style[0],highlightColor);
116122
done();
117123
});
118124
});
@@ -122,47 +128,47 @@ describe("openlayers_MapboxStyles", () => {
122128
mapboxStyles.on("styleloaded", () => {
123129
var style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
124130
expect(style).not.toBeNull();
125-
matchColor(style[0],defaultColor);
131+
matchFillColor(style[0],defaultColor);
126132
mapboxStyles.setSelectedObjects({ id: 1, sourceLayer: "Military_R@California" });
127133
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
128134
expect(style).not.toBeNull();
129-
matchColor(style[0],highlightColor);
135+
matchFillColor(style[0],highlightColor);
130136

131137
//add
132138
mapboxStyles.addSelectedObjects({ id: 2, sourceLayer: "Military_R@California" });
133139
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
134140
expect(style).not.toBeNull();
135-
matchColor(style[0],highlightColor);
141+
matchFillColor(style[0],highlightColor);
136142
style = mapboxStyles.getStyleFunction()(feature2, 2.388657133911758);
137143
expect(style).not.toBeNull();
138-
matchColor(style[0],highlightColor);
144+
matchFillColor(style[0],highlightColor);
139145

140146
//remove
141147
mapboxStyles.removeSelectedObjects({ id: 2, sourceLayer: "Military_R@California" });
142148
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
143149
expect(style).not.toBeNull();
144-
matchColor(style[0],highlightColor);
150+
matchFillColor(style[0],highlightColor);
145151
style = mapboxStyles.getStyleFunction()(feature2, 2.388657133911758);
146152
expect(style).not.toBeNull();
147-
matchColor(style[0],defaultColor);
153+
matchFillColor(style[0],defaultColor);
148154

149155
//set
150156
mapboxStyles.setSelectedObjects({ id: 2, sourceLayer: "Military_R@California" });
151157
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
152158
expect(style).not.toBeNull();
153-
matchColor(style[0],defaultColor);
159+
matchFillColor(style[0],defaultColor);
154160
style = mapboxStyles.getStyleFunction()(feature2, 2.388657133911758);
155161
expect(style).not.toBeNull();
156-
matchColor(style[0],highlightColor);
162+
matchFillColor(style[0],highlightColor);
157163

158164
//clear
159165
mapboxStyles.clearSelectedObjects();
160166
style = mapboxStyles.getStyleFunction()(feature, 2.388657133911758);
161167
expect(style).not.toBeNull();
162-
matchColor(style[0],defaultColor);
168+
matchFillColor(style[0],defaultColor);
163169
style = mapboxStyles.getStyleFunction()(feature2, 2.388657133911758);
164170
expect(style).not.toBeNull();
165-
matchColor(style[0],defaultColor);
171+
matchFillColor(style[0],defaultColor);
166172
done();
167173
});
168174
});

test/resources/MapboxStyles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ var vectorstylesEscapedJson={
3939
"maxzoom": 16,
4040
"paint": {
4141
"fill-color": "rgba(249,224,219,0.90)",
42-
"fill-antialias": true
42+
"fill-antialias": true,
43+
"fill-outline-color":"rgba(249,224,219,0.90)"
4344
},
4445
"id": "Military_R@California#26",
4546
"source": "California",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy