forked from tilemill-project/tilemill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreview.bones
63 lines (54 loc) · 1.72 KB
/
Preview.bones
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
view = Backbone.View.extend();
view.prototype.events = {
'click a.upload': 'upload'
};
view.prototype.initialize = function(options) {
_(this).bindAll('render');
Bones.utils.fetch({
preview: new models.Preview({id:this.model.get('filename')}),
config: new models.Config()
}, _(function(err, models) {
if (err) return new views.Modal(err);
this.preview = models.preview;
this.config = models.config;
this.render();
}).bind(this));
};
view.prototype.render = function() {
this.$('.content').html(templates.Preview({
model: this.model,
config: this.config
}));
if (!MM) throw new Error('ModestMaps not found.');
this.map = new MM.Map('preview',
new wax.mm.connector(this.preview.attributes));
wax.mm.interaction()
.map(this.map)
.tilejson(this.preview.attributes)
.on(wax.tooltip().parent(this.map.parent).events());
wax.mm.legend(this.map, this.preview.attributes).appendTo(this.map.parent);
wax.mm.zoombox(this.map);
wax.mm.zoomer(this.map).appendTo(this.map.parent);
var center = this.preview.get('center');
this.map.setCenterZoom(new MM.Location(
center[1],
center[0]),
center[2]);
this.map.setZoomRange(
this.model.get('minzoom'),
this.model.get('maxzoom'));
return this;
};
view.prototype.upload = function(ev) {
(new models.Export({
filename: this.model.get('filename'),
project: this.model.get('project'),
format: 'upload'
}).save({}, {
success: _(function(model) {
this.collection.add(model);
$('a.close', this.el).click();
}).bind(this)
}));
return false;
};