@progress/kendo-charts 1.21.0 → 1.23.0-dev.202201120958
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/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/barcode/barcode-validator.js +50 -0
- package/dist/es/barcode.js +1 -0
- package/dist/es/common/keys.js +25 -0
- package/dist/es/common.js +1 -0
- package/dist/es/drawing-utils.js +27 -3
- package/dist/es/main.js +1 -0
- package/dist/es/map/attribution.js +157 -0
- package/dist/es/map/crs.js +277 -0
- package/dist/es/map/datums.js +16 -0
- package/dist/es/map/extent.js +129 -0
- package/dist/es/map/layers/bubble.js +185 -0
- package/dist/es/map/layers/layer.js +140 -0
- package/dist/es/map/layers/marker.js +348 -0
- package/dist/es/map/layers/shape.js +390 -0
- package/dist/es/map/layers/tile.js +481 -0
- package/dist/es/map/location.js +201 -0
- package/dist/es/map/map.js +929 -0
- package/dist/es/map/navigator.js +174 -0
- package/dist/es/map/scroller/draggable.js +454 -0
- package/dist/es/map/scroller/fx.js +119 -0
- package/dist/es/map/scroller/observable.js +151 -0
- package/dist/es/map/scroller/scroller.js +746 -0
- package/dist/es/map/scroller/user-events.js +712 -0
- package/dist/es/map/utils.js +450 -0
- package/dist/es/map/zoom.js +139 -0
- package/dist/es/map.js +1 -0
- package/dist/es/qrcode/qrcode-validator.js +24 -0
- package/dist/es/qrcode.js +1 -0
- package/dist/es/services/map-service.js +15 -0
- package/dist/es2015/barcode/barcode-validator.js +48 -0
- package/dist/es2015/barcode.js +1 -0
- package/dist/es2015/common/keys.js +25 -0
- package/dist/es2015/common.js +1 -0
- package/dist/es2015/drawing-utils.js +43 -3
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/map/attribution.js +147 -0
- package/dist/es2015/map/crs.js +233 -0
- package/dist/es2015/map/datums.js +16 -0
- package/dist/es2015/map/extent.js +115 -0
- package/dist/es2015/map/layers/bubble.js +167 -0
- package/dist/es2015/map/layers/layer.js +134 -0
- package/dist/es2015/map/layers/marker.js +328 -0
- package/dist/es2015/map/layers/shape.js +370 -0
- package/dist/es2015/map/layers/tile.js +455 -0
- package/dist/es2015/map/location.js +193 -0
- package/dist/es2015/map/map.js +905 -0
- package/dist/es2015/map/navigator.js +169 -0
- package/dist/es2015/map/scroller/draggable.js +418 -0
- package/dist/es2015/map/scroller/fx.js +112 -0
- package/dist/es2015/map/scroller/observable.js +143 -0
- package/dist/es2015/map/scroller/scroller.js +716 -0
- package/dist/es2015/map/scroller/user-events.js +694 -0
- package/dist/es2015/map/utils.js +450 -0
- package/dist/es2015/map/zoom.js +134 -0
- package/dist/es2015/map.js +1 -0
- package/dist/es2015/qrcode/qrcode-validator.js +22 -0
- package/dist/es2015/qrcode.js +1 -0
- package/dist/es2015/services/map-service.js +15 -0
- package/dist/npm/barcode.d.ts +4 -1
- package/dist/npm/main.d.ts +2 -0
- package/dist/npm/main.js +6227 -329
- package/dist/npm/map.d.ts +4 -0
- package/dist/npm/qrcode.d.ts +3 -0
- package/dist/npm/validation.d.ts +9 -0
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import {
|
|
2
|
+
geometry as g,
|
|
3
|
+
throttle
|
|
4
|
+
} from '@progress/kendo-drawing';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Class,
|
|
8
|
+
addClass,
|
|
9
|
+
deepExtend,
|
|
10
|
+
round,
|
|
11
|
+
limitValue,
|
|
12
|
+
hashKey,
|
|
13
|
+
setDefaultOptions
|
|
14
|
+
} from '../../common';
|
|
15
|
+
|
|
16
|
+
import { Layer } from './layer';
|
|
17
|
+
|
|
18
|
+
import TemplateService from '../../services/template-service';
|
|
19
|
+
|
|
20
|
+
var math = Math,
|
|
21
|
+
template = TemplateService.compile,
|
|
22
|
+
Point = g.Point;
|
|
23
|
+
|
|
24
|
+
function roundPoint(point) {
|
|
25
|
+
return new Point(round(point.x), round(point.y));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function renderSize(size) {
|
|
29
|
+
var newSize = size;
|
|
30
|
+
|
|
31
|
+
if (typeof(size) !== "string") {
|
|
32
|
+
newSize += "px";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return newSize;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export var TileLayer = (function (Layer) {
|
|
39
|
+
function TileLayer(map, options) {
|
|
40
|
+
Layer.call(this, map, options);
|
|
41
|
+
|
|
42
|
+
if (typeof this.options.subdomains === 'string') {
|
|
43
|
+
this.options.subdomains = this.options.subdomains.split('');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var viewType = this._viewType();
|
|
47
|
+
this._view = new viewType(this.element, this.options);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if ( Layer ) TileLayer.__proto__ = Layer;
|
|
51
|
+
TileLayer.prototype = Object.create( Layer && Layer.prototype );
|
|
52
|
+
TileLayer.prototype.constructor = TileLayer;
|
|
53
|
+
|
|
54
|
+
TileLayer.prototype.destroy = function destroy () {
|
|
55
|
+
Layer.prototype.destroy.call(this);
|
|
56
|
+
this._view.destroy();
|
|
57
|
+
this._view = null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
TileLayer.prototype._beforeReset = function _beforeReset () {
|
|
61
|
+
var map = this.map;
|
|
62
|
+
var origin = map.locationToLayer(map.extent().nw).round();
|
|
63
|
+
this._view.viewOrigin(origin);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
TileLayer.prototype._reset = function _reset () {
|
|
67
|
+
Layer.prototype._reset.call(this);
|
|
68
|
+
this._updateView();
|
|
69
|
+
this._view.reset();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
TileLayer.prototype._viewType = function _viewType () {
|
|
73
|
+
return TileView;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
TileLayer.prototype._activate = function _activate () {
|
|
77
|
+
Layer.prototype._activate.call(this);
|
|
78
|
+
|
|
79
|
+
if (!this.support.mobileOS) {
|
|
80
|
+
if (!this._pan) {
|
|
81
|
+
this._pan = throttle(this._render.bind(this), 100);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.map.bind('pan', this._pan);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
TileLayer.prototype._deactivate = function _deactivate () {
|
|
89
|
+
Layer.prototype._deactivate.call(this);
|
|
90
|
+
|
|
91
|
+
if (this._pan) {
|
|
92
|
+
this.map.unbind('pan', this._pan);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
TileLayer.prototype._updateView = function _updateView () {
|
|
97
|
+
var view = this._view,
|
|
98
|
+
map = this.map,
|
|
99
|
+
extent = map.extent(),
|
|
100
|
+
extentToPoint = {
|
|
101
|
+
nw: map.locationToLayer(extent.nw).round(),
|
|
102
|
+
se: map.locationToLayer(extent.se).round()
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
view.center(map.locationToLayer(map.center()));
|
|
106
|
+
view.extent(extentToPoint);
|
|
107
|
+
view.zoom(map.zoom());
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
TileLayer.prototype._resize = function _resize () {
|
|
111
|
+
this._render();
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
TileLayer.prototype._panEnd = function _panEnd (e) {
|
|
115
|
+
Layer.prototype._panEnd.call(this, e);
|
|
116
|
+
this._render();
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
TileLayer.prototype._render = function _render () {
|
|
120
|
+
this._updateView();
|
|
121
|
+
this._view.render();
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return TileLayer;
|
|
125
|
+
}(Layer));
|
|
126
|
+
|
|
127
|
+
setDefaultOptions(TileLayer, {
|
|
128
|
+
tileSize: 256,
|
|
129
|
+
subdomains: ['a', 'b', 'c'],
|
|
130
|
+
urlTemplate: '',
|
|
131
|
+
zIndex: 1
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export var TileView = (function (Class) {
|
|
135
|
+
function TileView(element, options) {
|
|
136
|
+
Class.call(this);
|
|
137
|
+
this.element = element;
|
|
138
|
+
this._initOptions(options);
|
|
139
|
+
this.pool = new TilePool();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if ( Class ) TileView.__proto__ = Class;
|
|
143
|
+
TileView.prototype = Object.create( Class && Class.prototype );
|
|
144
|
+
TileView.prototype.constructor = TileView;
|
|
145
|
+
|
|
146
|
+
TileView.prototype._initOptions = function _initOptions (options) {
|
|
147
|
+
this.options = deepExtend({}, this.options, options);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
TileView.prototype.center = function center (center$1) {
|
|
151
|
+
this._center = center$1;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
TileView.prototype.extent = function extent (extent$1) {
|
|
155
|
+
this._extent = extent$1;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
TileView.prototype.viewOrigin = function viewOrigin (origin) {
|
|
159
|
+
this._viewOrigin = origin;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
TileView.prototype.zoom = function zoom (zoom$1) {
|
|
163
|
+
this._zoom = zoom$1;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
TileView.prototype.pointToTileIndex = function pointToTileIndex (point) {
|
|
167
|
+
return new Point(math.floor(point.x / this.options.tileSize), math.floor(point.y / this.options.tileSize));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
TileView.prototype.tileCount = function tileCount () {
|
|
171
|
+
var size = this.size(),
|
|
172
|
+
firstTileIndex = this.pointToTileIndex(this._extent.nw),
|
|
173
|
+
nw = this._extent.nw,
|
|
174
|
+
point = this.indexToPoint(firstTileIndex).translate(-nw.x, -nw.y);
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
x: math.ceil((math.abs(point.x) + size.width) / this.options.tileSize),
|
|
178
|
+
y: math.ceil((math.abs(point.y) + size.height) / this.options.tileSize)
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
TileView.prototype.size = function size () {
|
|
183
|
+
var nw = this._extent.nw,
|
|
184
|
+
se = this._extent.se,
|
|
185
|
+
diff = se.clone().translate(-nw.x, -nw.y);
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
width: diff.x,
|
|
189
|
+
height: diff.y
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
TileView.prototype.indexToPoint = function indexToPoint (index) {
|
|
194
|
+
var x = index.x,
|
|
195
|
+
y = index.y;
|
|
196
|
+
|
|
197
|
+
return new Point(x * this.options.tileSize, y * this.options.tileSize);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
TileView.prototype.subdomainText = function subdomainText () {
|
|
201
|
+
var subdomains = this.options.subdomains;
|
|
202
|
+
return subdomains[this.subdomainIndex++ % subdomains.length];
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
TileView.prototype.destroy = function destroy () {
|
|
206
|
+
this.element.empty();
|
|
207
|
+
this.pool.empty();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
TileView.prototype.reset = function reset () {
|
|
211
|
+
this.pool.reset();
|
|
212
|
+
this.subdomainIndex = 0;
|
|
213
|
+
this.render();
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
TileView.prototype.render = function render () {
|
|
217
|
+
var this$1 = this;
|
|
218
|
+
|
|
219
|
+
var size = this.tileCount(),
|
|
220
|
+
firstTileIndex = this.pointToTileIndex(this._extent.nw),
|
|
221
|
+
tile, x, y;
|
|
222
|
+
|
|
223
|
+
for (x = 0; x < size.x; x++) {
|
|
224
|
+
for (y = 0; y < size.y; y++) {
|
|
225
|
+
tile = this$1.createTile({
|
|
226
|
+
x: firstTileIndex.x + x,
|
|
227
|
+
y: firstTileIndex.y + y
|
|
228
|
+
});
|
|
229
|
+
if (!tile.visible) {
|
|
230
|
+
tile.show();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
TileView.prototype.createTile = function createTile (currentIndex) {
|
|
237
|
+
var options = this.tileOptions(currentIndex);
|
|
238
|
+
var tile = this.pool.get(this._center, options);
|
|
239
|
+
|
|
240
|
+
if (!tile.element.parentNode) {
|
|
241
|
+
this.element.append(tile.element);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return tile;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
TileView.prototype.tileOptions = function tileOptions (currentIndex) {
|
|
248
|
+
var index = this.wrapIndex(currentIndex),
|
|
249
|
+
point = this.indexToPoint(currentIndex),
|
|
250
|
+
origin = this._viewOrigin,
|
|
251
|
+
offset = point.clone().translate(-origin.x, -origin.y);
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
index: index,
|
|
255
|
+
currentIndex: currentIndex,
|
|
256
|
+
point: point,
|
|
257
|
+
offset: roundPoint(offset),
|
|
258
|
+
zoom: this._zoom,
|
|
259
|
+
size: this.options.tileSize,
|
|
260
|
+
subdomain: this.subdomainText(),
|
|
261
|
+
urlTemplate: this.options.urlTemplate,
|
|
262
|
+
errorUrlTemplate: this.options.errorUrlTemplate
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
TileView.prototype.wrapIndex = function wrapIndex (index) {
|
|
267
|
+
var boundary = math.pow(2, this._zoom);
|
|
268
|
+
return {
|
|
269
|
+
x: this.wrapValue(index.x, boundary),
|
|
270
|
+
y: limitValue(index.y, 0, boundary - 1)
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
TileView.prototype.wrapValue = function wrapValue (value, boundary) {
|
|
275
|
+
var remainder = math.abs(value) % boundary;
|
|
276
|
+
var wrappedValue = value;
|
|
277
|
+
|
|
278
|
+
if (value >= 0) {
|
|
279
|
+
wrappedValue = remainder;
|
|
280
|
+
} else {
|
|
281
|
+
wrappedValue = boundary - (remainder === 0 ? boundary : remainder);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return wrappedValue;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
return TileView;
|
|
288
|
+
}(Class));
|
|
289
|
+
|
|
290
|
+
export var ImageTile = (function (Class) {
|
|
291
|
+
function ImageTile(id, options) {
|
|
292
|
+
Class.call(this);
|
|
293
|
+
this.id = id;
|
|
294
|
+
this.visible = true;
|
|
295
|
+
this._initOptions(options);
|
|
296
|
+
this.createElement();
|
|
297
|
+
this.show();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if ( Class ) ImageTile.__proto__ = Class;
|
|
301
|
+
ImageTile.prototype = Object.create( Class && Class.prototype );
|
|
302
|
+
ImageTile.prototype.constructor = ImageTile;
|
|
303
|
+
|
|
304
|
+
ImageTile.prototype.destroy = function destroy () {
|
|
305
|
+
if (this.element) {
|
|
306
|
+
this.element.remove();
|
|
307
|
+
this.element = null;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
ImageTile.prototype._initOptions = function _initOptions (options) {
|
|
312
|
+
this.options = deepExtend({}, this.options, options);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
ImageTile.prototype.createElement = function createElement () {
|
|
316
|
+
var el = document.createElement("img");
|
|
317
|
+
addClass(el, "k-layer");
|
|
318
|
+
el.style.position = "absolute";
|
|
319
|
+
el.style.display = "block";
|
|
320
|
+
el.style.width = this.options.size;
|
|
321
|
+
el.style.height = this.options.size;
|
|
322
|
+
|
|
323
|
+
this.element = el;
|
|
324
|
+
|
|
325
|
+
// todo
|
|
326
|
+
// add on error handler
|
|
327
|
+
|
|
328
|
+
// this.element =
|
|
329
|
+
// $('<img style=\'position: absolute; display: block;\' alt=\'\' />')
|
|
330
|
+
// .css({
|
|
331
|
+
// width: this.options.size,
|
|
332
|
+
// height: this.options.size
|
|
333
|
+
// })
|
|
334
|
+
// .on('error', proxy(function(e) {
|
|
335
|
+
// if (this.errorUrl()) {
|
|
336
|
+
// e.target.setAttribute('src', this.errorUrl());
|
|
337
|
+
// } else {
|
|
338
|
+
// e.target.removeAttribute('src');
|
|
339
|
+
// }
|
|
340
|
+
// }, this));
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
ImageTile.prototype.show = function show () {
|
|
344
|
+
var element = this.element;
|
|
345
|
+
element.style.top = renderSize(this.options.offset.y);
|
|
346
|
+
element.style.left = renderSize(this.options.offset.x);
|
|
347
|
+
|
|
348
|
+
var url = this.url();
|
|
349
|
+
|
|
350
|
+
if (url) {
|
|
351
|
+
element.setAttribute('src', url);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
element.style.visibility = 'visible';
|
|
355
|
+
this.visible = true;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
ImageTile.prototype.hide = function hide () {
|
|
359
|
+
this.element.style.visibility = 'hidden';
|
|
360
|
+
this.visible = false;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
ImageTile.prototype.url = function url () {
|
|
364
|
+
var urlResult = template(this.options.urlTemplate);
|
|
365
|
+
return urlResult(this.urlOptions());
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
ImageTile.prototype.errorUrl = function errorUrl () {
|
|
369
|
+
var urlResult = template(this.options.errorUrlTemplate);
|
|
370
|
+
return urlResult(this.urlOptions());
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
ImageTile.prototype.urlOptions = function urlOptions () {
|
|
374
|
+
var options = this.options;
|
|
375
|
+
|
|
376
|
+
return {
|
|
377
|
+
zoom: options.zoom,
|
|
378
|
+
subdomain: options.subdomain,
|
|
379
|
+
z: options.zoom,
|
|
380
|
+
x: options.index.x,
|
|
381
|
+
y: options.index.y,
|
|
382
|
+
s: options.subdomain,
|
|
383
|
+
quadkey: options.quadkey,
|
|
384
|
+
q: options.quadkey,
|
|
385
|
+
culture: options.culture,
|
|
386
|
+
c: options.culture
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
return ImageTile;
|
|
391
|
+
}(Class));
|
|
392
|
+
|
|
393
|
+
setDefaultOptions(ImageTile, {
|
|
394
|
+
urlTemplate: '',
|
|
395
|
+
errorUrlTemplate: ''
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
export var TilePool = (function (Class) {
|
|
399
|
+
function TilePool() {
|
|
400
|
+
Class.call(this);
|
|
401
|
+
this._items = [];
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if ( Class ) TilePool.__proto__ = Class;
|
|
405
|
+
TilePool.prototype = Object.create( Class && Class.prototype );
|
|
406
|
+
TilePool.prototype.constructor = TilePool;
|
|
407
|
+
|
|
408
|
+
TilePool.prototype.get = function get (center, options) {
|
|
409
|
+
if (this._items.length >= this.options.maxSize) {
|
|
410
|
+
this._remove(center);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return this._create(options);
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
TilePool.prototype.empty = function empty () {
|
|
417
|
+
var items = this._items;
|
|
418
|
+
|
|
419
|
+
for (var i = 0; i < items.length; i++) {
|
|
420
|
+
items[i].destroy();
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
this._items = [];
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
TilePool.prototype.reset = function reset () {
|
|
427
|
+
var items = this._items;
|
|
428
|
+
|
|
429
|
+
for (var i = 0; i < items.length; i++) {
|
|
430
|
+
items[i].hide();
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
TilePool.prototype._create = function _create (options) {
|
|
435
|
+
var items = this._items;
|
|
436
|
+
var tile;
|
|
437
|
+
var id = hashKey(options.point.toString() + options.offset.toString() + options.zoom + options.urlTemplate);
|
|
438
|
+
|
|
439
|
+
for (var i = 0; i < items.length; i++) {
|
|
440
|
+
if (items[i].id === id) {
|
|
441
|
+
tile = items[i];
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (tile) {
|
|
447
|
+
tile.show();
|
|
448
|
+
} else {
|
|
449
|
+
tile = new ImageTile(id, options);
|
|
450
|
+
this._items.push(tile);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return tile;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
TilePool.prototype._remove = function _remove (center) {
|
|
457
|
+
var items = this._items;
|
|
458
|
+
var maxDist = -1;
|
|
459
|
+
var index = -1;
|
|
460
|
+
|
|
461
|
+
for (var i = 0; i < items.length; i++) {
|
|
462
|
+
var dist = items[i].options.point.distanceTo(center);
|
|
463
|
+
|
|
464
|
+
if (dist > maxDist && !items[i].visible) {
|
|
465
|
+
index = i;
|
|
466
|
+
maxDist = dist;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (index !== -1) {
|
|
471
|
+
items[index].destroy();
|
|
472
|
+
items.splice(index, 1);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
return TilePool;
|
|
477
|
+
}(Class));
|
|
478
|
+
|
|
479
|
+
setDefaultOptions(TilePool, {
|
|
480
|
+
maxSize: 100
|
|
481
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Class,
|
|
3
|
+
deepExtend,
|
|
4
|
+
deg,
|
|
5
|
+
rad,
|
|
6
|
+
round,
|
|
7
|
+
defined
|
|
8
|
+
} from '../common';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
datums
|
|
12
|
+
} from './datums';
|
|
13
|
+
|
|
14
|
+
function toSquare(value) {
|
|
15
|
+
return value * value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var math = Math,
|
|
20
|
+
abs = math.abs,
|
|
21
|
+
atan = math.atan,
|
|
22
|
+
atan2 = math.atan2,
|
|
23
|
+
cos = math.cos,
|
|
24
|
+
sin = math.sin,
|
|
25
|
+
tan = math.tan;
|
|
26
|
+
|
|
27
|
+
export var Location = (function (Class) {
|
|
28
|
+
function Location(lat, lng) {
|
|
29
|
+
Class.call(this);
|
|
30
|
+
|
|
31
|
+
this.initProperties();
|
|
32
|
+
|
|
33
|
+
if (arguments.length === 1) {
|
|
34
|
+
this.lat = lat[0];
|
|
35
|
+
this.lng = lat[1];
|
|
36
|
+
} else {
|
|
37
|
+
this.lat = lat;
|
|
38
|
+
this.lng = lng;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ( Class ) Location.__proto__ = Class;
|
|
43
|
+
Location.prototype = Object.create( Class && Class.prototype );
|
|
44
|
+
Location.prototype.constructor = Location;
|
|
45
|
+
|
|
46
|
+
Location.prototype.initProperties = function initProperties () {
|
|
47
|
+
deepExtend(this, {
|
|
48
|
+
DISTANCE_ITERATIONS: 100,
|
|
49
|
+
DISTANCE_CONVERGENCE: 1e-12,
|
|
50
|
+
DISTANCE_PRECISION: 2,
|
|
51
|
+
FORMAT: '{0:N6}{1:N6}'
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Location.prototype.toArray = function toArray () {
|
|
56
|
+
return [
|
|
57
|
+
this.lat,
|
|
58
|
+
this.lng
|
|
59
|
+
];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
Location.prototype.equals = function equals (loc) {
|
|
63
|
+
return loc && loc.lat === this.lat && loc.lng === this.lng;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Location.prototype.clone = function clone () {
|
|
67
|
+
return new Location(this.lat, this.lng);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
Location.prototype.round = function round$1 (precision) {
|
|
71
|
+
this.lng = round(this.lng, precision);
|
|
72
|
+
this.lat = round(this.lat, precision);
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
Location.prototype.wrap = function wrap () {
|
|
77
|
+
this.lng = this.lng % 180;
|
|
78
|
+
this.lat = this.lat % 90;
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Location.prototype.distanceTo = function distanceTo (dest, datum) {
|
|
83
|
+
return this.greatCircleTo(dest, datum).distance;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
Location.prototype.destination = function destination (distance, initialBearing, initialDatum) {
|
|
87
|
+
var bearing = rad(initialBearing);
|
|
88
|
+
var datum = initialDatum || datums.WGS84;
|
|
89
|
+
var fromLat = rad(this.lat);
|
|
90
|
+
var fromLng = rad(this.lng);
|
|
91
|
+
var dToR = distance / datum.a;
|
|
92
|
+
var lat = math.asin(sin(fromLat) * cos(dToR) + cos(fromLat) * sin(dToR) * cos(bearing));
|
|
93
|
+
var lng = fromLng + atan2(sin(bearing) * sin(dToR) * cos(fromLat), cos(dToR) - sin(fromLat) * sin(lat));
|
|
94
|
+
|
|
95
|
+
return new Location(deg(lat), deg(lng));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
Location.prototype.greatCircleTo = function greatCircleTo (initialDest, initialDatum) {
|
|
99
|
+
var this$1 = this;
|
|
100
|
+
|
|
101
|
+
var dest = Location.create(dest);
|
|
102
|
+
var datum = initialDatum || datums.WGS84;
|
|
103
|
+
|
|
104
|
+
if (!dest || this.clone().round(8).equals(dest.clone().round(8))) {
|
|
105
|
+
return {
|
|
106
|
+
distance: 0,
|
|
107
|
+
azimuthFrom: 0,
|
|
108
|
+
azimuthTo: 0
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// See http://en.wikipedia.org/wiki/Vincenty's_formulae#Notation
|
|
113
|
+
// o == sigma
|
|
114
|
+
// A == alpha
|
|
115
|
+
|
|
116
|
+
var a = datum.a;
|
|
117
|
+
var b = datum.b;
|
|
118
|
+
var f = datum.f;
|
|
119
|
+
var L = rad(dest.lng - this.lng);
|
|
120
|
+
var U1 = atan((1 - f) * tan(rad(this.lat)));
|
|
121
|
+
var sinU1 = sin(U1);
|
|
122
|
+
var cosU1 = cos(U1);
|
|
123
|
+
var U2 = atan((1 - f) * tan(rad(dest.lat)));
|
|
124
|
+
var sinU2 = sin(U2);
|
|
125
|
+
var cosU2 = cos(U2);
|
|
126
|
+
var lambda = L;
|
|
127
|
+
var prevLambda;
|
|
128
|
+
var i = this.DISTANCE_ITERATIONS;
|
|
129
|
+
var converged = false;
|
|
130
|
+
var sinLambda;
|
|
131
|
+
var cosLambda;
|
|
132
|
+
var sino;
|
|
133
|
+
var cosA2;
|
|
134
|
+
var coso;
|
|
135
|
+
var cos2om;
|
|
136
|
+
var sigma;
|
|
137
|
+
|
|
138
|
+
while (!converged && i-- > 0) {
|
|
139
|
+
sinLambda = sin(lambda);
|
|
140
|
+
cosLambda = cos(lambda);
|
|
141
|
+
sino = math.sqrt(toSquare(cosU2 * sinLambda) + toSquare(cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
|
|
142
|
+
coso = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
|
|
143
|
+
sigma = atan2(sino, coso);
|
|
144
|
+
|
|
145
|
+
var sinA = cosU1 * cosU2 * sinLambda / sino;
|
|
146
|
+
cosA2 = 1 - toSquare(sinA);
|
|
147
|
+
cos2om = 0;
|
|
148
|
+
|
|
149
|
+
if (cosA2 !== 0) {
|
|
150
|
+
cos2om = coso - 2 * sinU1 * sinU2 / cosA2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
prevLambda = lambda;
|
|
154
|
+
var C = f / 16 * cosA2 * (4 + f * (4 - 3 * cosA2));
|
|
155
|
+
lambda = L + (1 - C) * f * sinA * (sigma + C * sino * (cos2om + C * coso * (-1 + 2 * toSquare(cos2om))));
|
|
156
|
+
converged = abs(lambda - prevLambda) <= this$1.DISTANCE_CONVERGENCE;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
var u2 = cosA2 * (toSquare(a) - toSquare(b)) / toSquare(b);
|
|
160
|
+
var A = 1 + u2 / 16384 * (4096 + u2 * (-768 + u2 * (320 - 175 * u2)));
|
|
161
|
+
var B = u2 / 1024 * (256 + u2 * (-128 + u2 * (74 - 47 * u2)));
|
|
162
|
+
var deltao = B * sino * (cos2om + B / 4 * (coso * (-1 + 2 * toSquare(cos2om)) - B / 6 * cos2om * (-3 + 4 * toSquare(sino)) * (-3 + 4 * toSquare(cos2om))));
|
|
163
|
+
|
|
164
|
+
var azimuthFrom = atan2(cosU2 * sinLambda, cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
|
|
165
|
+
var azimuthTo = atan2(cosU1 * sinLambda, -sinU1 * cosU2 + cosU1 * sinU2 * cosLambda);
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
distance: round(b * A * (sigma - deltao), this.DISTANCE_PRECISION),
|
|
169
|
+
azimuthFrom: deg(azimuthFrom),
|
|
170
|
+
azimuthTo: deg(azimuthTo)
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// IE < 9 doesn't allow to override toString on definition
|
|
175
|
+
Location.prototype.toString = function toString () {
|
|
176
|
+
// return kendo.format(this.FORMAT, this.lat, this.lng);
|
|
177
|
+
return String(this.lat) + "," + String(this.lng);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
Location.fromLngLat = function fromLngLat (lngAndLat) {
|
|
181
|
+
return new Location(lngAndLat[1], lngAndLat[0]);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
Location.fromLatLng = function fromLatLng (lngAndLat) {
|
|
185
|
+
return new Location(lngAndLat[0], lngAndLat[1]);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
Location.create = function create (a, b) {
|
|
189
|
+
if (defined(a)) {
|
|
190
|
+
if (a instanceof Location) {
|
|
191
|
+
return a.clone();
|
|
192
|
+
} else if (arguments.length === 1 && a.length === 2) {
|
|
193
|
+
return Location.fromLatLng(a);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return new Location(a, b);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
return Location;
|
|
201
|
+
}(Class));
|