Skip to content

Commit 2b92766

Browse files
fix 修复 leaflet fgb 自定义 style 会引用与增加ol 包私有方法检测方法
1 parent 802087b commit 2b92766

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

build/webpack.config.openlayers.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
var configBase = require('./webpack.config.base');
2+
var fs = require('fs');
3+
const chalk = require('chalk');
24
//端名
35
var libName = 'openlayers';
46
//产品包名
@@ -11,6 +13,7 @@ if (origin && origin.includes('deploy-ol')) {
1113
libName = 'ol';
1214
productName = 'iclient-ol';
1315
}
16+
1417
var externals = [
1518
Object.assign({}, configBase.externals, {
1619
'@turf/turf': 'function(){try{return turf}catch(e){return {}}}()',
@@ -32,6 +35,23 @@ var externals = [
3235
}
3336
];
3437

38+
var methodNames = ['bindFeaturesCollection_', 'addFeaturesInternal'];
39+
checkPrivateMethodExists(methodNames);
40+
41+
function checkPrivateMethodExists(methodNames) {
42+
const file_path = 'node_modules/ol/dist/ol.js';
43+
try {
44+
const data = fs.readFileSync(file_path, 'utf8');
45+
methodNames.forEach((methodName) => {
46+
if (!data.includes(methodName)) {
47+
console.log(chalk.red(`方法 ${methodName} 不存在于混淆后的 ol 中 ${file_path},测试 ol fgb 重写方法是否被调用`));
48+
}
49+
});
50+
} catch (err) {
51+
console.error('读取文件出错:', err);
52+
}
53+
}
54+
3555
module.exports = {
3656
target: configBase.target,
3757
mode: configBase.mode,

src/leaflet/core/Base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ L.GeoJSON.include({
128128
layer.defaultOptions = layer.options;
129129
var defaultGeometryOptions = this.defaultGeometryOptions[geometry.type];
130130
if (defaultGeometryOptions) {
131-
layer.commonOptions = defaultGeometryOptions;
131+
layer.commonOptions = Object.assign({}, defaultGeometryOptions);
132132
} else {
133133
this.defaultGeometryOptions[geometry.type] = L.Util.extend({}, layer.defaultOptions);
134134
}

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