gridviz 3.0.26 → 3.0.27
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/README.md +128 -128
- package/dist/gridviz.js +8630 -8620
- package/dist/gridviz.min.js +1 -1
- package/package.json +73 -73
- package/src/button/Button.js +67 -67
- package/src/button/FullscreenButton.js +121 -121
- package/src/button/ZoomButtons.js +103 -103
- package/src/core/Dataset.js +154 -154
- package/src/core/Drawable.js +78 -78
- package/src/core/GeoCanvas.js +443 -443
- package/src/core/Layer.js +23 -23
- package/src/core/Legend.js +108 -108
- package/src/core/Map.js +544 -544
- package/src/core/MultiResolutionDataset.js +93 -93
- package/src/core/Style.js +98 -98
- package/src/core/Tooltip.js +182 -182
- package/src/dataset/COGeo.js +25 -25
- package/src/dataset/CSVGrid.js +112 -112
- package/src/dataset/GeoTIFF.js +122 -122
- package/src/dataset/JSGrid.js +55 -55
- package/src/dataset/TiledGrid.js +302 -302
- package/src/dataset/worker.js +18 -18
- package/src/index.js +77 -77
- package/src/layer/BackgroundLayer.js +173 -173
- package/src/layer/BackgroundLayerImage.js +81 -81
- package/src/layer/BackgroundLayerWMS.js +104 -104
- package/src/layer/GeoJSONLayer.js +224 -214
- package/src/layer/GridLayer.js +148 -148
- package/src/layer/LabelLayer.js +194 -194
- package/src/legend/ColorCategoryLegend.js +109 -109
- package/src/legend/ColorDiscreteLegend.js +100 -100
- package/src/legend/ColorLegend.js +115 -115
- package/src/legend/OrientationLegend.js +89 -89
- package/src/legend/SizeLegend.js +224 -224
- package/src/legend/TernaryLegend.js +302 -302
- package/src/style/CompositionStyle.js +291 -291
- package/src/style/ContourStyle.js +21 -21
- package/src/style/DotDensityStyle.js +133 -133
- package/src/style/ImageStyle.js +100 -100
- package/src/style/IsoFenceStyle.js +217 -217
- package/src/style/JoyPlotStyle.js +127 -127
- package/src/style/LegoStyle.js +110 -110
- package/src/style/MosaicStyle.js +99 -99
- package/src/style/NinjaStarStyle.js +102 -102
- package/src/style/PillarStyle.js +207 -207
- package/src/style/SegmentStyle.js +105 -105
- package/src/style/ShapeColorSizeStyle.js +147 -147
- package/src/style/SideCategoryStyle.js +112 -112
- package/src/style/SideStyle.js +212 -212
- package/src/style/SquareColorCategoryWebGLStyle.js +107 -107
- package/src/style/SquareColorWebGLStyle.js +126 -126
- package/src/style/StrokeStyle.js +135 -135
- package/src/style/TanakaStyle.js +69 -69
- package/src/style/TextStyle.js +110 -110
- package/src/style/TimeSeriesStyle.js +222 -222
- package/src/utils/WebGLRectangleColoring.js +106 -106
- package/src/utils/WebGLSquareColoring.js +118 -118
- package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
- package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
- package/src/utils/WebGLSquareColoringKS.js +153 -153
- package/src/utils/scale.js +218 -218
- package/src/utils/stretching.js +120 -120
- package/src/utils/ternary.js +208 -208
- package/src/utils/utils.js +58 -58
- package/src/utils/webGLUtils.js +72 -72
- package/src/utils/zoomUtils.js +142 -142
package/src/utils/webGLUtils.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} width
|
|
6
|
-
* @param {string} height
|
|
7
|
-
* @param {object} opts
|
|
8
|
-
* @returns {{canvas:HTMLCanvasElement, gl:WebGLRenderingContext}}
|
|
9
|
-
*/
|
|
10
|
-
export function makeWebGLCanvas(width, height, opts = {}) {
|
|
11
|
-
const canvas = document.createElement('canvas')
|
|
12
|
-
canvas.setAttribute('width', width)
|
|
13
|
-
canvas.setAttribute('height', height)
|
|
14
|
-
/** @type {WebGLRenderingContext} */
|
|
15
|
-
const gl = canvas.getContext('webgl', opts)
|
|
16
|
-
if (!gl) {
|
|
17
|
-
throw new Error('Unable to initialize WebGL. Your browser or machine may not support it.')
|
|
18
|
-
}
|
|
19
|
-
return { canvas: canvas, gl: gl }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Initialize a shader program, so WebGL knows how to draw our data
|
|
24
|
-
*
|
|
25
|
-
* @param {WebGLRenderingContext} gl
|
|
26
|
-
* @param {...WebGLShader} shaders
|
|
27
|
-
* @returns {WebGLProgram}
|
|
28
|
-
*/
|
|
29
|
-
export function initShaderProgram(gl, ...shaders) {
|
|
30
|
-
/** @type {WebGLProgram|null} */
|
|
31
|
-
const program = gl.createProgram()
|
|
32
|
-
if (program == null) throw new Error('Cannot create webGL program')
|
|
33
|
-
for (const shader of shaders) gl.attachShader(program, shader)
|
|
34
|
-
gl.linkProgram(program)
|
|
35
|
-
if (gl.getProgramParameter(program, gl.LINK_STATUS)) return program
|
|
36
|
-
throw new Error(gl.getProgramInfoLog(program) || 'Cannot create webGL program (2)')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Creates a shader of the given type, uploads the source and compiles it.
|
|
41
|
-
*
|
|
42
|
-
* @param {WebGLRenderingContext} gl
|
|
43
|
-
* @param {number} type
|
|
44
|
-
* @param {...string} sources
|
|
45
|
-
* @returns {WebGLShader}
|
|
46
|
-
*/
|
|
47
|
-
export function createShader(gl, type, ...sources) {
|
|
48
|
-
/** @type {WebGLShader|null} */
|
|
49
|
-
const shader = gl.createShader(type)
|
|
50
|
-
if (shader == null) throw new Error('Cannot create webGL shader')
|
|
51
|
-
gl.shaderSource(shader, sources.join('\n'))
|
|
52
|
-
gl.compileShader(shader)
|
|
53
|
-
if (gl.getShaderParameter(shader, gl.COMPILE_STATUS)) return shader
|
|
54
|
-
throw new Error(gl.getShaderInfoLog(shader) || 'Cannot create webGL shader (2)')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Check if webGL is supported
|
|
59
|
-
*
|
|
60
|
-
* @returns {boolean}
|
|
61
|
-
*/
|
|
62
|
-
export function checkWebGLSupport() {
|
|
63
|
-
try {
|
|
64
|
-
const canvas = document.createElement('canvas')
|
|
65
|
-
return !!(
|
|
66
|
-
!!window.WebGLRenderingContext &&
|
|
67
|
-
(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
|
|
68
|
-
)
|
|
69
|
-
} catch (err) {
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} width
|
|
6
|
+
* @param {string} height
|
|
7
|
+
* @param {object} opts
|
|
8
|
+
* @returns {{canvas:HTMLCanvasElement, gl:WebGLRenderingContext}}
|
|
9
|
+
*/
|
|
10
|
+
export function makeWebGLCanvas(width, height, opts = {}) {
|
|
11
|
+
const canvas = document.createElement('canvas')
|
|
12
|
+
canvas.setAttribute('width', width)
|
|
13
|
+
canvas.setAttribute('height', height)
|
|
14
|
+
/** @type {WebGLRenderingContext} */
|
|
15
|
+
const gl = canvas.getContext('webgl', opts)
|
|
16
|
+
if (!gl) {
|
|
17
|
+
throw new Error('Unable to initialize WebGL. Your browser or machine may not support it.')
|
|
18
|
+
}
|
|
19
|
+
return { canvas: canvas, gl: gl }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Initialize a shader program, so WebGL knows how to draw our data
|
|
24
|
+
*
|
|
25
|
+
* @param {WebGLRenderingContext} gl
|
|
26
|
+
* @param {...WebGLShader} shaders
|
|
27
|
+
* @returns {WebGLProgram}
|
|
28
|
+
*/
|
|
29
|
+
export function initShaderProgram(gl, ...shaders) {
|
|
30
|
+
/** @type {WebGLProgram|null} */
|
|
31
|
+
const program = gl.createProgram()
|
|
32
|
+
if (program == null) throw new Error('Cannot create webGL program')
|
|
33
|
+
for (const shader of shaders) gl.attachShader(program, shader)
|
|
34
|
+
gl.linkProgram(program)
|
|
35
|
+
if (gl.getProgramParameter(program, gl.LINK_STATUS)) return program
|
|
36
|
+
throw new Error(gl.getProgramInfoLog(program) || 'Cannot create webGL program (2)')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a shader of the given type, uploads the source and compiles it.
|
|
41
|
+
*
|
|
42
|
+
* @param {WebGLRenderingContext} gl
|
|
43
|
+
* @param {number} type
|
|
44
|
+
* @param {...string} sources
|
|
45
|
+
* @returns {WebGLShader}
|
|
46
|
+
*/
|
|
47
|
+
export function createShader(gl, type, ...sources) {
|
|
48
|
+
/** @type {WebGLShader|null} */
|
|
49
|
+
const shader = gl.createShader(type)
|
|
50
|
+
if (shader == null) throw new Error('Cannot create webGL shader')
|
|
51
|
+
gl.shaderSource(shader, sources.join('\n'))
|
|
52
|
+
gl.compileShader(shader)
|
|
53
|
+
if (gl.getShaderParameter(shader, gl.COMPILE_STATUS)) return shader
|
|
54
|
+
throw new Error(gl.getShaderInfoLog(shader) || 'Cannot create webGL shader (2)')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Check if webGL is supported
|
|
59
|
+
*
|
|
60
|
+
* @returns {boolean}
|
|
61
|
+
*/
|
|
62
|
+
export function checkWebGLSupport() {
|
|
63
|
+
try {
|
|
64
|
+
const canvas = document.createElement('canvas')
|
|
65
|
+
return !!(
|
|
66
|
+
!!window.WebGLRenderingContext &&
|
|
67
|
+
(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
|
|
68
|
+
)
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/utils/zoomUtils.js
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {import("../App").App} app
|
|
7
|
-
* @param {number} zTarget
|
|
8
|
-
* @param {number} factor
|
|
9
|
-
* @param {number} delayMs
|
|
10
|
-
* @param {function|undefined} callback
|
|
11
|
-
* @param {number} delayBeforeCallBackMs
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export function zoomTo(
|
|
15
|
-
app,
|
|
16
|
-
zTarget,
|
|
17
|
-
factor = 1.01,
|
|
18
|
-
delayMs = 0,
|
|
19
|
-
callback = undefined,
|
|
20
|
-
delayBeforeCallBackMs = 0
|
|
21
|
-
) {
|
|
22
|
-
//ensure good factor value: >1
|
|
23
|
-
factor = factor || 1.01
|
|
24
|
-
if (factor < 1) {
|
|
25
|
-
console.error('Unexpected value for factor: ' + factor + '. Set to default value 1.01')
|
|
26
|
-
factor = 1.01
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const zIni = map.getZoom()
|
|
30
|
-
if (zTarget == zIni) return
|
|
31
|
-
if (zTarget < zIni) factor = 1 / factor
|
|
32
|
-
let z = zIni
|
|
33
|
-
let timer = setInterval(() => {
|
|
34
|
-
//compute new zoom level
|
|
35
|
-
z = map.getZoom() * factor
|
|
36
|
-
if (zTarget > zIni && z > zTarget) z = zTarget
|
|
37
|
-
if (zTarget < zIni && z < zTarget) z = zTarget
|
|
38
|
-
|
|
39
|
-
//set new zoom level
|
|
40
|
-
map.setZoom(z)
|
|
41
|
-
map.redraw()
|
|
42
|
-
|
|
43
|
-
//target reached
|
|
44
|
-
if (z == zTarget) {
|
|
45
|
-
clearInterval(timer)
|
|
46
|
-
//trigger callback, if any
|
|
47
|
-
if (callback)
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
callback()
|
|
50
|
-
}, delayBeforeCallBackMs)
|
|
51
|
-
}
|
|
52
|
-
}, delayMs)
|
|
53
|
-
return timer
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {import("../App").App} app
|
|
59
|
-
* @param {number} xTarget
|
|
60
|
-
* @param {number} yTarget
|
|
61
|
-
* @param {number} zTarget
|
|
62
|
-
* @param {number} progressFactorPix
|
|
63
|
-
* @param {number} delayMs
|
|
64
|
-
* @param {function|undefined} callback
|
|
65
|
-
* @param {number} delayBeforeCallBackMs
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
export function goToStraight(
|
|
69
|
-
app,
|
|
70
|
-
xTarget = NaN,
|
|
71
|
-
yTarget = NaN,
|
|
72
|
-
zTarget = NaN,
|
|
73
|
-
progressFactorPix = 5,
|
|
74
|
-
delayMs = 0,
|
|
75
|
-
callback = undefined,
|
|
76
|
-
delayBeforeCallBackMs = 0
|
|
77
|
-
) {
|
|
78
|
-
//store initial position/zoom
|
|
79
|
-
const zIni = map.getZoom()
|
|
80
|
-
const cIni = map.getView()
|
|
81
|
-
|
|
82
|
-
//default
|
|
83
|
-
xTarget = isNaN(xTarget) ? cIni.x : xTarget
|
|
84
|
-
yTarget = isNaN(yTarget) ? cIni.y : yTarget
|
|
85
|
-
zTarget = isNaN(zTarget) ? zIni : zTarget
|
|
86
|
-
|
|
87
|
-
//prepare for pan
|
|
88
|
-
const dx = xTarget - cIni.x
|
|
89
|
-
const dy = yTarget - cIni.y
|
|
90
|
-
let d = Math.hypot(dx, dy)
|
|
91
|
-
const ddx = (progressFactorPix * zIni * dx) / d
|
|
92
|
-
const ddy = (progressFactorPix * zIni * dy) / d
|
|
93
|
-
|
|
94
|
-
//prepare for zoom
|
|
95
|
-
let r = zTarget / zIni
|
|
96
|
-
const n = d / (progressFactorPix * zIni)
|
|
97
|
-
const zoomFactor = d > 0 ? Math.pow(r, 1 / n) : Math.pow(r, 1 / 10) //TODO not 10 ?
|
|
98
|
-
|
|
99
|
-
//timer
|
|
100
|
-
let timer = setInterval(() => {
|
|
101
|
-
//compute and set new position
|
|
102
|
-
if (d > 0) {
|
|
103
|
-
const c = map.getView()
|
|
104
|
-
let nx = c.x + ddx
|
|
105
|
-
let ny = c.y + ddy
|
|
106
|
-
//if went too far, stop at target values
|
|
107
|
-
if (nx < xTarget && xTarget < c.x) nx = xTarget
|
|
108
|
-
if (c.x < xTarget && xTarget < nx) nx = xTarget
|
|
109
|
-
if (ny < yTarget && yTarget < c.y) ny = yTarget
|
|
110
|
-
if (c.y < yTarget && yTarget < ny) ny = yTarget
|
|
111
|
-
map.setGeoCenter({ x: nx, y: ny })
|
|
112
|
-
if (nx == xTarget && ny == yTarget) d = 0
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//compute and set new zoom
|
|
116
|
-
if (r != 1) {
|
|
117
|
-
const z = map.getZoom()
|
|
118
|
-
let nz = zoomFactor * z
|
|
119
|
-
//if went too far, stop at target values
|
|
120
|
-
if (nz < zTarget && zTarget < z) nz = zTarget
|
|
121
|
-
if (z < zTarget && zTarget < nz) nz = zTarget
|
|
122
|
-
map.setZoom(nz)
|
|
123
|
-
if (nz == zTarget) r = 1
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//redraw
|
|
127
|
-
map.redraw()
|
|
128
|
-
|
|
129
|
-
//if target reached, stop
|
|
130
|
-
if (d == 0 && r == 1) {
|
|
131
|
-
//console.log("OK !")
|
|
132
|
-
clearInterval(timer)
|
|
133
|
-
//trigger callback, if any
|
|
134
|
-
if (callback)
|
|
135
|
-
setTimeout(() => {
|
|
136
|
-
callback()
|
|
137
|
-
}, delayBeforeCallBackMs)
|
|
138
|
-
}
|
|
139
|
-
}, delayMs)
|
|
140
|
-
|
|
141
|
-
return timer
|
|
142
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {import("../App").App} app
|
|
7
|
+
* @param {number} zTarget
|
|
8
|
+
* @param {number} factor
|
|
9
|
+
* @param {number} delayMs
|
|
10
|
+
* @param {function|undefined} callback
|
|
11
|
+
* @param {number} delayBeforeCallBackMs
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function zoomTo(
|
|
15
|
+
app,
|
|
16
|
+
zTarget,
|
|
17
|
+
factor = 1.01,
|
|
18
|
+
delayMs = 0,
|
|
19
|
+
callback = undefined,
|
|
20
|
+
delayBeforeCallBackMs = 0
|
|
21
|
+
) {
|
|
22
|
+
//ensure good factor value: >1
|
|
23
|
+
factor = factor || 1.01
|
|
24
|
+
if (factor < 1) {
|
|
25
|
+
console.error('Unexpected value for factor: ' + factor + '. Set to default value 1.01')
|
|
26
|
+
factor = 1.01
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const zIni = map.getZoom()
|
|
30
|
+
if (zTarget == zIni) return
|
|
31
|
+
if (zTarget < zIni) factor = 1 / factor
|
|
32
|
+
let z = zIni
|
|
33
|
+
let timer = setInterval(() => {
|
|
34
|
+
//compute new zoom level
|
|
35
|
+
z = map.getZoom() * factor
|
|
36
|
+
if (zTarget > zIni && z > zTarget) z = zTarget
|
|
37
|
+
if (zTarget < zIni && z < zTarget) z = zTarget
|
|
38
|
+
|
|
39
|
+
//set new zoom level
|
|
40
|
+
map.setZoom(z)
|
|
41
|
+
map.redraw()
|
|
42
|
+
|
|
43
|
+
//target reached
|
|
44
|
+
if (z == zTarget) {
|
|
45
|
+
clearInterval(timer)
|
|
46
|
+
//trigger callback, if any
|
|
47
|
+
if (callback)
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
callback()
|
|
50
|
+
}, delayBeforeCallBackMs)
|
|
51
|
+
}
|
|
52
|
+
}, delayMs)
|
|
53
|
+
return timer
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {import("../App").App} app
|
|
59
|
+
* @param {number} xTarget
|
|
60
|
+
* @param {number} yTarget
|
|
61
|
+
* @param {number} zTarget
|
|
62
|
+
* @param {number} progressFactorPix
|
|
63
|
+
* @param {number} delayMs
|
|
64
|
+
* @param {function|undefined} callback
|
|
65
|
+
* @param {number} delayBeforeCallBackMs
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
export function goToStraight(
|
|
69
|
+
app,
|
|
70
|
+
xTarget = NaN,
|
|
71
|
+
yTarget = NaN,
|
|
72
|
+
zTarget = NaN,
|
|
73
|
+
progressFactorPix = 5,
|
|
74
|
+
delayMs = 0,
|
|
75
|
+
callback = undefined,
|
|
76
|
+
delayBeforeCallBackMs = 0
|
|
77
|
+
) {
|
|
78
|
+
//store initial position/zoom
|
|
79
|
+
const zIni = map.getZoom()
|
|
80
|
+
const cIni = map.getView()
|
|
81
|
+
|
|
82
|
+
//default
|
|
83
|
+
xTarget = isNaN(xTarget) ? cIni.x : xTarget
|
|
84
|
+
yTarget = isNaN(yTarget) ? cIni.y : yTarget
|
|
85
|
+
zTarget = isNaN(zTarget) ? zIni : zTarget
|
|
86
|
+
|
|
87
|
+
//prepare for pan
|
|
88
|
+
const dx = xTarget - cIni.x
|
|
89
|
+
const dy = yTarget - cIni.y
|
|
90
|
+
let d = Math.hypot(dx, dy)
|
|
91
|
+
const ddx = (progressFactorPix * zIni * dx) / d
|
|
92
|
+
const ddy = (progressFactorPix * zIni * dy) / d
|
|
93
|
+
|
|
94
|
+
//prepare for zoom
|
|
95
|
+
let r = zTarget / zIni
|
|
96
|
+
const n = d / (progressFactorPix * zIni)
|
|
97
|
+
const zoomFactor = d > 0 ? Math.pow(r, 1 / n) : Math.pow(r, 1 / 10) //TODO not 10 ?
|
|
98
|
+
|
|
99
|
+
//timer
|
|
100
|
+
let timer = setInterval(() => {
|
|
101
|
+
//compute and set new position
|
|
102
|
+
if (d > 0) {
|
|
103
|
+
const c = map.getView()
|
|
104
|
+
let nx = c.x + ddx
|
|
105
|
+
let ny = c.y + ddy
|
|
106
|
+
//if went too far, stop at target values
|
|
107
|
+
if (nx < xTarget && xTarget < c.x) nx = xTarget
|
|
108
|
+
if (c.x < xTarget && xTarget < nx) nx = xTarget
|
|
109
|
+
if (ny < yTarget && yTarget < c.y) ny = yTarget
|
|
110
|
+
if (c.y < yTarget && yTarget < ny) ny = yTarget
|
|
111
|
+
map.setGeoCenter({ x: nx, y: ny })
|
|
112
|
+
if (nx == xTarget && ny == yTarget) d = 0
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//compute and set new zoom
|
|
116
|
+
if (r != 1) {
|
|
117
|
+
const z = map.getZoom()
|
|
118
|
+
let nz = zoomFactor * z
|
|
119
|
+
//if went too far, stop at target values
|
|
120
|
+
if (nz < zTarget && zTarget < z) nz = zTarget
|
|
121
|
+
if (z < zTarget && zTarget < nz) nz = zTarget
|
|
122
|
+
map.setZoom(nz)
|
|
123
|
+
if (nz == zTarget) r = 1
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//redraw
|
|
127
|
+
map.redraw()
|
|
128
|
+
|
|
129
|
+
//if target reached, stop
|
|
130
|
+
if (d == 0 && r == 1) {
|
|
131
|
+
//console.log("OK !")
|
|
132
|
+
clearInterval(timer)
|
|
133
|
+
//trigger callback, if any
|
|
134
|
+
if (callback)
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
callback()
|
|
137
|
+
}, delayBeforeCallBackMs)
|
|
138
|
+
}
|
|
139
|
+
}, delayMs)
|
|
140
|
+
|
|
141
|
+
return timer
|
|
142
|
+
}
|