cartodb/lib/assets/javascripts/dashboard/data/map-model.js
2020-06-15 10:58:47 +08:00

27 lines
665 B
JavaScript

const Backbone = require('backbone');
const LayersCollection = require('dashboard/data/layers-collection');
const checkAndBuildOpts = require('builder/helpers/required-opts');
const REQUIRED_OPTS = [
'configModel'
];
const MapModel = Backbone.Model.extend({
urlRoot: '/api/v1/maps',
initialize: function (options) {
checkAndBuildOpts(options, REQUIRED_OPTS, this);
this.bind('change:id', this._fetchLayers, this);
this.layers = new LayersCollection(null, { configModel: this._configModel });
this.layers.map = this;
},
// fetch related layers
_fetchLayers: function () {
this.layers.fetch();
}
});
module.exports = MapModel;