raintee-maputils 1.0.15 → 1.0.16
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/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/index.js +8 -8
- package/package.json +2 -3
- package/src/CustomOptionsControl.js +0 -169
- package/src/CustomToggleControl.js +0 -126
- package/src/RainteeConstants.js +0 -820
- package/src/RainteeGISUtil.js +0 -149
- package/src/RainteeSourceMapTool.js +0 -104
- package/src/RasterLayerController.js +0 -262
- package/src/TerrainToggleControl.js +0 -127
- package/src/useDrawCache.js +0 -61
package/src/useDrawCache.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const taskQueue = [];
|
|
2
|
-
const addTask = (task) => {
|
|
3
|
-
taskQueue.push(task)
|
|
4
|
-
}
|
|
5
|
-
const runTask = () => {
|
|
6
|
-
|
|
7
|
-
if (taskQueue.length > 0) {
|
|
8
|
-
const task = taskQueue.shift()
|
|
9
|
-
let drawCacheIndex = localStorage.getItem('drawCacheIndex') != null ? JSON.parse(localStorage.getItem('drawCacheIndex')) : []
|
|
10
|
-
if (task.action === 'add') {
|
|
11
|
-
drawCacheIndex.push(String(task.data.id))
|
|
12
|
-
localStorage.setItem(String(task.data.id), JSON.stringify(task.data))
|
|
13
|
-
} else if (task.action === 'remove') {
|
|
14
|
-
let index = drawCacheIndex.indexOf(String(task.data.id))
|
|
15
|
-
if (index !== -1) {
|
|
16
|
-
drawCacheIndex.splice(index, 1)
|
|
17
|
-
localStorage.removeItem(String(task.data.id))
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
localStorage.setItem('drawCacheIndex', JSON.stringify(drawCacheIndex))
|
|
21
|
-
runTask()
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const addFeature = (feature) => {
|
|
25
|
-
addTask({
|
|
26
|
-
action: 'add',
|
|
27
|
-
data: feature
|
|
28
|
-
})
|
|
29
|
-
runTask()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const removeFeature = (feature) => {
|
|
33
|
-
addTask({
|
|
34
|
-
action: 'remove',
|
|
35
|
-
data: feature
|
|
36
|
-
})
|
|
37
|
-
runTask()
|
|
38
|
-
}
|
|
39
|
-
const getDrawCache = () => {
|
|
40
|
-
let drawCacheIndex = localStorage.getItem('drawCacheIndex') != null ? JSON.parse(localStorage.getItem('drawCacheIndex')) : []
|
|
41
|
-
let drawCache = drawCacheIndex.map(item => {
|
|
42
|
-
return JSON.parse(localStorage.getItem(item))
|
|
43
|
-
})
|
|
44
|
-
return drawCache
|
|
45
|
-
}
|
|
46
|
-
const clearDrawCache = () => {
|
|
47
|
-
let drawCacheIndex = localStorage.getItem('drawCacheIndex') != null ? JSON.parse(localStorage.getItem('drawCacheIndex')) : []
|
|
48
|
-
drawCacheIndex.forEach(item => {
|
|
49
|
-
localStorage.removeItem(item)
|
|
50
|
-
})
|
|
51
|
-
localStorage.removeItem('drawCacheIndex')
|
|
52
|
-
}
|
|
53
|
-
const useDrawCache = () => {
|
|
54
|
-
return {
|
|
55
|
-
addFeature,
|
|
56
|
-
removeFeature,
|
|
57
|
-
getDrawCache,
|
|
58
|
-
clearDrawCache
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export { useDrawCache }
|