-
Notifications
You must be signed in to change notification settings - Fork 1
/
SavedMapLayer.js
46 lines (40 loc) · 1.36 KB
/
SavedMapLayer.js
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
var SavedMapLayer = OpenLayers.Class(OpenLayers.Layer.XYZ, {
async: true,
fs: null,
uuid: null,
transitionEffect: 'resize',
initialize: function(name, options) {
var url = '${z}/${x}/${y}.png';
OpenLayers.Layer.XYZ.prototype.initialize.apply(this,
[name, url, options]);
},
getXYZ: function(bounds) {
var res = this.getServerResolution();
var x = Math.round((bounds.left - this.maxExtent.left) /
(res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.maxExtent.bottom) /
(res * this.tileSize.h));
var z = this.getServerZoom();
if (this.wrapDateLine) {
var limit = Math.pow(2, z);
x = ((x % limit) + limit) % limit;
}
return {'x': x, 'y': y, 'z': z};
},
getURLasync: function(bounds, callback, scope) {
var url = this.getURL(bounds);
var path = Ext.os.is.Android ?
"Android/data/com.c2c.LuxMob/" : "";
var fileName = this.uuid + '_' + url.replace(/\//g,'_');
this.fs.root.getFile(
path + fileName,
null,
function(fileEntry) {
callback.call(scope, fileEntry.toURL());
},
function(error) {
console.log("error getting file : " + fileName);
}
);
}
});