Skip to content

Commit 63f7509

Browse files
committed
2 parents 2f778a9 + 54f37ff commit 63f7509

File tree

9 files changed

+79
-88
lines changed

9 files changed

+79
-88
lines changed

build/publish.js

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,20 @@
1-
var fs = require('fs');
2-
var path = require('path');
3-
var key = process.argv[2] ? process.argv[2].replace("--", "") : "leaflet";
4-
var filePath = path.join(__dirname, "../dist");
5-
var destDir = path.join(__dirname, "../src/" + key + "/dist");
6-
if (!fs.existsSync(destDir)) {
7-
fs.mkdirSync(destDir);
8-
}
9-
fs.readdir(path.join(filePath, key), function (err, files) {
10-
if (err) {
11-
console.log(err);
12-
return;
1+
const path = require('path');
2+
const fse = require('fs-extra')
3+
4+
const key = process.argv[2] ? process.argv[2].replace("--", "") : "leaflet";
5+
const sourceDir = path.join(__dirname, "../dist/" + key);
6+
const destDir = path.join(__dirname, "../src/" + key + "/dist");
7+
8+
fse.removeSync(destDir);
9+
fse.copySync(sourceDir, destDir, {
10+
filter: (src) => {
11+
return !(src.indexOf("include-") >= 0 || src.indexOf("resources") >= 0)
1312
}
14-
files.forEach(function (fileName) {
15-
if (fileName.indexOf(key) >= 0 && fileName.indexOf("include") == -1) {
16-
var sourceFile = path.join(__dirname, "../dist/" + key, fileName);
17-
var destPath = path.join(__dirname, "../src/" + key + "/dist", fileName);
18-
var readStream = fs.createReadStream(sourceFile);
19-
var writeStream = fs.createWriteStream(destPath);
20-
readStream.pipe(writeStream);
21-
return;
22-
}
23-
//workers
24-
if (fs.statSync(path.join(filePath, key, fileName)).isDirectory()) {
25-
if (!fs.existsSync(path.join(__dirname, "../src/" + key + "/dist/", fileName))) {
26-
fs.mkdirSync(path.join(__dirname, "../src/" + key + "/dist/", fileName));
27-
}
28-
fs.readdir(path.join(filePath, key, fileName), function (err, subfiles) {
29-
if (err) {
30-
console.log(err);
31-
return;
32-
}
33-
subfiles.forEach(function (subfileName) {
34-
var sourceFile = path.join(__dirname, "../dist/", key, fileName, subfileName);
35-
var destPath = path.join(__dirname, "../src/" + key + "/dist/", fileName, subfileName);
36-
var readStream = fs.createReadStream(sourceFile);
37-
var writeStream = fs.createWriteStream(destPath);
38-
readStream.pipe(writeStream);
39-
})
40-
})
41-
}
42-
})
43-
})
13+
});
14+
if (key === 'mapboxgl') {
15+
// 拷贝resources文件夹到src/mapboxgl
16+
const source = path.join(__dirname, "../dist/resources");
17+
const target = path.join(__dirname, "../src/mapboxgl/resources");
18+
fse.removeSync(target);
19+
fse.copySync(source, target);
20+
}

build/webpack.config.mapboxgl.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ const configBase = require('./webpack.config.base');
33
const libName = 'mapboxgl';
44
//产品包名
55
const productName = 'iclient-mapboxgl';
6+
//复制文件
7+
const CopyPlugin = require("copy-webpack-plugin");
68

79
module.exports = {
810
target: configBase.target,
911
mode: configBase.mode,
1012
//页面入口文件配置
11-
entry: [...configBase.entry, `${__dirname}/../src/mapboxgl/namespace.js` ,`${__dirname}/../src/mapboxgl/css/index.js`],
13+
entry: [...configBase.entry, `${__dirname}/../src/mapboxgl/namespace.js`, `${__dirname}/../src/mapboxgl/css/index.js`],
1214
//入口文件输出配置
1315
output: configBase.output(libName, productName),
1416
//是否启用压缩
@@ -33,7 +35,7 @@ module.exports = {
3335
module: {
3436
noParse: /[\/\\]node_modules[\/\\]mapbox-gl[\/\\]dist[\/\\]mapbox-gl\.js$/,
3537

36-
rules: (function() {
38+
rules: (function () {
3739
let moduleRules = [];
3840
moduleRules.push(configBase.module.rules.img);
3941
const babelConfig = {
@@ -44,16 +46,16 @@ module.exports = {
4446
presets: ['@babel/preset-env'],
4547
plugins: [
4648
[
47-
'@babel/plugin-transform-runtime',
48-
{
49-
absoluteRuntime: false,
50-
corejs: false,
51-
helpers: false,
52-
regenerator: true,
53-
useESModules: false
54-
}
49+
'@babel/plugin-transform-runtime',
50+
{
51+
absoluteRuntime: false,
52+
corejs: false,
53+
helpers: false,
54+
regenerator: true,
55+
useESModules: false
56+
}
5557
]
56-
]
58+
]
5759
}
5860
}
5961
configBase.moduleVersion === "es6" && (babelConfig.include = /FGBLayer|flatgeobuf/);
@@ -62,5 +64,12 @@ module.exports = {
6264
return moduleRules;
6365
})()
6466
},
65-
plugins: configBase.plugins(libName, productName)
67+
plugins: [
68+
...configBase.plugins(libName, productName),
69+
new CopyPlugin({
70+
patterns: [
71+
{ from: `${__dirname}/../dist/resources/symbols`, to: `${__dirname}/../dist/mapboxgl/resources/symbols` }
72+
]
73+
})
74+
]
6675
};

examples/mapboxgl/websymbol-editor/js/websymbol-editor.js

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

examples/mapboxgl/websymbol-gallery/js/websymbol-gallery.js

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

examples/mapboxgl/websymbol_YangtzeRiverdelta.html

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -244,38 +244,34 @@
244244
});
245245
};
246246

247-
var addSource = function () {
247+
map.on("load", function () {
248+
// 配置基础路径
249+
new mapboxgl.supermap.WebSymbol().init({basePath: window.exampleWebSymbolBasePath});
248250
var uploadedDataURL = "../data/yangtze-river-delta.json";
249251
$.get(uploadedDataURL, function (data) {
250252
map.addSource("sanjiaozhou", {
251253
type: "geojson",
252254
data: data,
253255
});
254-
});
255-
};
256-
257-
map.on("load", function () {
258-
// 配置基础路径
259-
new mapboxgl.supermap.WebSymbol().init({basePath: window.exampleWebSymbolBasePath});
260-
addSource();
261-
loadSymbols().then(function () {
262-
createPolygonLayer("Frame", "polygon-955463");
263-
createPolygonLayer("Province_R", "polygon-955464");
264-
createPolygonLayer("SuHuZhe_R", "polygon-955514");
265-
createPolygonLayer("Lake_R", "polygon-955463");
266-
createPolygonLayer("River_R", "polygon-955463");
267-
createPolygonLayer("MainRiver_R", "polygon-955463");
268-
createPolygonLayer("SuHuZheInsideBuffer", "polygon-955441");
269-
createPolygonLayer("SuHuZheBuffer2", "polygon-955383");
270-
createPolygonLayer("SuHuZheBuffer1", "polygon-955453");
271-
createLineLayer("Frame", "line-962558");
272-
createLineLayer("Province_L", "line-964890");
273-
createLineLayer("Coast_L", "line-962614");
274-
createLineLayer("City_L", "line-962475");
275-
createLineLayer("SuHuZheInside_L", "line-964890");
276-
createLineLayer("SuHuZhe_L", "line-964890");
277-
createTextLayer();
278-
createDevelopLayer();
256+
loadSymbols().then(function () {
257+
createPolygonLayer("Frame", "polygon-955463");
258+
createPolygonLayer("Province_R", "polygon-955464");
259+
createPolygonLayer("SuHuZhe_R", "polygon-955514");
260+
createPolygonLayer("Lake_R", "polygon-955463");
261+
createPolygonLayer("River_R", "polygon-955463");
262+
createPolygonLayer("MainRiver_R", "polygon-955463");
263+
createPolygonLayer("SuHuZheInsideBuffer", "polygon-955441");
264+
createPolygonLayer("SuHuZheBuffer2", "polygon-955383");
265+
createPolygonLayer("SuHuZheBuffer1", "polygon-955453");
266+
createLineLayer("Frame", "line-962558");
267+
createLineLayer("Province_L", "line-964890");
268+
createLineLayer("Coast_L", "line-962614");
269+
createLineLayer("City_L", "line-962475");
270+
createLineLayer("SuHuZheInside_L", "line-964890");
271+
createLineLayer("SuHuZhe_L", "line-964890");
272+
createTextLayer();
273+
createDevelopLayer();
274+
});
279275
});
280276
});
281277

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"release": "npm run release-leaflet && npm run release-openlayers && npm run release-mapboxgl && npm run release-classic && npm run release-maplibregl",
1515
"release-leaflet": "npm run release-leaflet-es5 && npm run release-leaflet-es6",
1616
"release-openlayers": "npm run release-openlayers-es5 && npm run release-openlayers-es6 && npm run release-ol-es5 && npm run release-ol-es6",
17-
"release-mapboxgl": "npm run release-mapboxgl-es5 && npm run release-mapboxgl-es6 && copyfiles -u 1 ./dist/resources/** ./dist/mapboxgl/",
17+
"release-mapboxgl": "npm run release-mapboxgl-es5 && npm run release-mapboxgl-es6",
1818
"release-maplibregl": "npm run release-maplibregl-es5 && npm run release-maplibregl-es6",
1919
"release-classic": "npm run release-classic-es5 && npm run release-classic-es6",
2020
"release-leaflet-es5": "cross-env moduleVersion=es5 npm run deploy-leaflet && uglifyjs ./dist/leaflet/iclient-leaflet.js --ecma 5 --comments /iclient-/i -c -m -o ./dist/leaflet/iclient-leaflet.min.js && cleancss -o ./dist/leaflet/iclient-leaflet.min.css ./dist/leaflet/iclient-leaflet.css",
@@ -47,9 +47,8 @@
4747
"build-docs-mapboxgl": "rimraf ./docs/mapboxgl && jsdoc -c ./build/jsdocs/mapboxgl/docs.json -R ./build/jsdocs/mapboxgl/index.md",
4848
"build-docs-maplibregl": "rimraf ./docs/maplibregl && jsdoc -c ./build/jsdocs/maplibregl/docs.json -R ./build/jsdocs/maplibregl/index.md",
4949
"build-docs-classic": "rimraf ./docs/classic && jsdoc -c ./build/jsdocs/classic/docs.json -R ./build/jsdocs/classic/index.md",
50-
"pre-publish": "node ./build/publish.js --leaflet && node ./build/publish.js --openlayers && node ./build/publish.js --mapboxgl && node ./build/publish.js --maplibregl && node ./build/publish.js --classic && npm run pre-publish-symbol",
51-
"publish": "npm run pre-publish && cd ./src/common && npm publish && cd ../leaflet && npm publish && cd ../openlayers && npm publish && cd ../mapboxgl && npm publish && cd ../maplibregl && npm publish && cd ../classic && npm publish",
52-
"pre-publish-symbol": "copyfiles -u 1 ./dist/resources/** ./src/mapboxgl/ "
50+
"pre-publish": "node ./build/publish.js --leaflet && node ./build/publish.js --openlayers && node ./build/publish.js --mapboxgl && node ./build/publish.js --maplibregl && node ./build/publish.js --classic",
51+
"publish": "npm run pre-publish && cd ./src/common && npm publish && cd ../leaflet && npm publish && cd ../openlayers && npm publish && cd ../mapboxgl && npm publish && cd ../maplibregl && npm publish && cd ../classic && npm publish"
5352
},
5453
"keywords": [
5554
"SuperMap",
@@ -87,7 +86,7 @@
8786
"chromedriver": "87.0.5",
8887
"clean-css-cli": "^4.3.0",
8988
"commander": "^9.0.0",
90-
"copyfiles": "^2.4.1",
89+
"copy-webpack-plugin": "^9.1.0",
9190
"cross-env": "^7.0.2",
9291
"css-loader": "^6.7.1",
9392
"elasticsearch": "16.7.3",
@@ -96,6 +95,7 @@
9695
"eslint-plugin-import": "^2.22.1",
9796
"eslint-webpack-plugin": "^2.1.0",
9897
"express": "^4.17.1",
98+
"fs-extra": "^11.1.1",
9999
"get-pixels": "^3.3.2",
100100
"image-size": "^0.9.2",
101101
"istanbul": "^0.4.5",

src/mapboxgl/overlay/symbol/MapExtendSymbol.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function MapExtendSymbol(){
2020
if (!mapboxgl.Map.prototype.symbolHandler) {
2121
mapboxgl.Map.prototype.symbolHandler = new SymbolHandler(map);
2222
}
23-
return mapboxgl.Map.prototype.symbolHandler;
23+
return mapboxgl.Map.prototype.symbolHandler._update(map);
2424
}
2525

2626
if (mapboxgl.Map.prototype.addLayerBySymbolBak === undefined) {

src/mapboxgl/overlay/symbol/SingleSymbolRender.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class SingleSymbolRender {
1717
* @param {*} before
1818
*/
1919
addLayer(layer, symbol, before) {
20-
delete symbol.layout?.visibility;
20+
if(layer.layout && layer.layout.visibility === 'none') {
21+
Object.assign(layer.layout, {visibility: 'visible'});
22+
}
2123
layer.paint && Object.assign(symbol.paint ?? {}, layer.paint);
2224
layer.layout && Object.assign(symbol.layout ?? {}, layer.layout);
2325
this.map.addLayerBySymbolBak({ ...layer, ...symbol }, before);

src/mapboxgl/overlay/symbol/SymbolHandler.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class SymbolHandler {
2323
this.#layerSymbols = {};
2424
}
2525

26+
_update(map) {
27+
this.map = map;
28+
return this;
29+
}
30+
2631
/**
2732
* 添加符号图层
2833
* @param {Object} layer
@@ -339,7 +344,7 @@ class SymbolHandler {
339344
*/
340345
moveLayer(layerId, beforeId) {
341346
const layerIds = this.getLayerIds(layerId);
342-
const realBeforeId = beforeId && (this.map.style.getLayer(beforeId)?.id ?? this.getFirstLayerId(beforeId));
347+
const realBeforeId = beforeId && (this.map.style.getLayer(beforeId)?.id ?? this.getFirstLayerId(beforeId));
343348
if (layerIds?.length > 0) {
344349
layerIds.forEach(id => this.map.style.moveLayer(id, realBeforeId));
345350
} else {

0 commit comments

Comments
 (0)