cartodb-4.42/lib/assets/javascripts/dashboard/data/map-model.js

27 lines
665 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
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;