forked from tilemill-project/tilemill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatasource.bones
35 lines (30 loc) · 1.02 KB
/
Datasource.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
// Datasource (read-only)
// ----------------------
// Model. Inspection metadata about a map layer. Use `fetchFeatures()` to do
// a datasource fetch that includes layer feature objects.
model = Backbone.Model.extend({});
// @TODO either as a feature or a bug, object attributes are not set
// automatically when passed to the constructor. We set it manually here.
model.prototype.initialize = function(attributes, options) {
this.set({'fields': attributes.fields});
this.options = options;
};
model.prototype.url = function() {
if (Bones.server) return;
var attr = this.attributes;
if (this.getFeatures) attr.features = true;
if (this.getInfo) attr.info = true;
return 'http://'
+ window.abilities.tileUrl
+ '/datasource/'
+ this.get('id')
+ '?' + $.param(attr);
};
model.prototype.fetchFeatures = function(options) {
this.getFeatures = true;
this.fetch(options);
};
model.prototype.fetchInfo = function(options) {
this.getInfo = true;
this.fetch(options);
};