Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
map-demo
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-02-08 10:42:16 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b6f8fa0fd1db2d32c82e7e8e22bc75c8039bc69d
b6f8fa0f
1 parent
0acf082a
fix 生成图片时间戳优化
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
src/utils/TileCutter.js
src/utils/TileCutter.js
View file @
b6f8fa0
/*
* @Date: 2025-01-22 11:45:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
1-24 16:56:06
* @LastEditTime: 2025-0
2-08 10:24:25
* @FilePath: /map-demo/src/utils/TileCutter.js
* @Description: 文件描述
*/
import
JSZip
from
"jszip"
;
import
{
saveAs
}
from
"file-saver"
;
import
dayjs
from
"dayjs"
;
const
tileSize
=
512
;
...
...
@@ -85,8 +86,11 @@ function sliceImageToTiles(image, bounds, zoomLevel) {
// console.warn(`保存瓦片: ${tileX}_${tileY}_${zoomLevel}.png`);
// saveTile(blob, `${tileX}_${tileY}_${zoomLevel}.png`);
// 获取当前北京时间(UTC+8)
const
beijingTime
=
dayjs
().
add
(
8
,
"hour"
).
toDate
();
// 使用 JSZip 将每个瓦片添加到压缩包中
zip
.
file
(
`
${
tileX
}
_
${
tileY
}
_
${
zoomLevel
}
.png`
,
blob
);
zip
.
file
(
`
${
tileX
}
_
${
tileY
}
_
${
zoomLevel
}
.png`
,
blob
,
{
date
:
beijingTime
}
);
tileIndex
++
;
// 如果所有瓦片都处理完,生成并下载压缩包
...
...
Please
register
or
login
to post a comment