forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmock_leaflet.js
More file actions
41 lines (39 loc) · 1.34 KB
/
mock_leaflet.js
File metadata and controls
41 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export function mockCreateTile() {
spyOn(L.TileLayer.prototype, 'createTile').and.callFake(function (coords, done) {
var tile = document.createElement('img');
L.DomEvent.on(tile, 'load', L.Util.bind(this._tileOnLoad, this, done, tile));
L.DomEvent.on(tile, 'error', L.Util.bind(this._tileOnError, this, done, tile));
if (this.options.crossOrigin || this.options.crossOrigin === '') {
tile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;
}
tile.alt = '';
tile.setAttribute('role', 'presentation');
this.getTileUrl(coords);
return tile;
});
}
export function mockInitImage() {
spyOn(L.ImageOverlay.prototype, '_initImage').and.callFake(function () {
this._image = L.DomUtil.create('img');
var me = this;
setTimeout(function () {
me.fire('load', {});
}, 1000);
});
}
export function mockHeatLayer() {
L.HeatLayer = (L.Layer ? L.Layer : L.Class).extend({
initialize: function (latlngs, options) {
this._latlngs = latlngs;
L.setOptions(this, options);
},
onAdd: function (map) {
this._map = map;
},
onRemove: function (map) {
},
});
L.heatLayer = function () {
return new L.HeatLayer();
};
}