-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbitstore.js
More file actions
89 lines (76 loc) · 2.42 KB
/
bitstore.js
File metadata and controls
89 lines (76 loc) · 2.42 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Minimal implementation of bitstore_min.js
* This provides the necessary classes and methods for the Safecast map to load properly
*/
// Define LBITSOptions class
function LBITSOptions() {
this.url = "";
this.url_template = "";
this.url_subdomains = ["a", "b", "c"];
this.url_subdomain_mode = 0;
this.url_suffix = "";
this.url_extension = "";
this.url_scheme = "https";
this.url_dir = "";
this.url_tilepath = "";
this.url_quadkey = false;
this.url_y_flipped = false;
this.min_zoom = 0;
this.max_zoom = 18;
this.tile_size = 256;
this.opacity = 1.0;
this.attribution = "";
}
// Define LBITS class
function LBITS(options) {
this.options = options || new LBITSOptions();
this.map = null;
this.tiles = {};
this.tileSize = this.options.tile_size || 256;
this.minZoom = this.options.min_zoom || 0;
this.maxZoom = this.options.max_zoom || 18;
this.name = 'LBITS Layer';
this.alt = '';
this.opacity = this.options.opacity || 1.0;
this.attribution = this.options.attribution || '';
}
// Add required methods to LBITS
LBITS.prototype.ShouldLoadTile = function(tileCoord, zoom) {
// Always return true to load all tiles
return true;
};
LBITS.prototype.GetTileUrl = function(tileCoord, zoom) {
// Generate a URL for the tile
var url = this.options.url || "";
if (this.options.url_template) {
url = this.options.url_template
.replace('{x}', tileCoord.x)
.replace('{y}', tileCoord.y)
.replace('{z}', zoom);
// Handle subdomains if specified
if (this.options.url_subdomains && this.options.url_subdomains.length > 0) {
var subdomain = this.options.url_subdomains[Math.abs(tileCoord.x + tileCoord.y) % this.options.url_subdomains.length];
url = url.replace('{s}', subdomain);
}
}
return url;
};
LBITS.prototype.SetOpacity = function(opacity) {
this.opacity = opacity;
};
// Define Bitstore class
function Bitstore() {
this.layers = {};
}
Bitstore.prototype.AddLayer = function(id, options) {
this.layers[id] = new LBITS(options);
return this.layers[id];
};
Bitstore.prototype.GetLayer = function(id) {
return this.layers[id] || null;
};
// Export classes to global scope
window.LBITSOptions = LBITSOptions;
window.LBITS = LBITS;
window.Bitstore = Bitstore;
console.log('Bitstore implementation loaded successfully');