"use strict"; /** * @typedef {import("./LayerModel.ecma.js").LayerModel} LayerModel */ import {MapDriverInterface} from "../Interfaces/MapDriverInterface.ecma.js"; import {CoordenatesModel} from "./CoordenatesModel.ecma.js"; import {EventModel} from "./EventModel.ecma.js"; /** * @class * @constructor * @param {!LayerModel} layer * @param {!string} name * @param {!string} key * @param {!string} data * @returns {void} * @access public * @static */ export const LayerItemModel = (function(){ /** * @constructs LayerItemModel * @param {!LayerModel} layer * @param {!string} name * @param {!string} key * @param {!string} data * @returns {void} * @access private * @static */ const LayerItemModel = function(layer, name, key, data, position, size){ /** @type {LayerItemModel} */ const self = this; /** @type {LayerModel} */ this.layer = layer; /** @type {string} */ this.key = key; /** @type {string} */ this.name = name; /** @type {string} */ this.data = data; /** @type {MapDriverInterface|null} */ this.item = null; /** @type {MapDriverInterface|null} */ this.from = null; /** @type {MapDriverInterface|null} */ this.to = null; /** @type {CoordenatesModel} */ this.position = position; /** @type {CoordenatesModel} */ this.size = size; /** @type {object.} */ this.attributes = { /** @type {boolean} */ visible : true, /** @type {boolean} */ selected : true }; /** @type {EventModel} */ this.on_change_position = new EventModel(); /** @type {EventModel} */ this.on_change_size = new EventModel(); /** * @returns {void} * @access private */ const constructor = () => { self.on_change_position.add((_, longitude, latitude) => { self.position = new CoordenatesModel(longitude, latitude); update_form(); }); self.on_change_size.add((_, longitude, latitude) => { self.size = new CoordenatesModel(longitude, latitude); update_form(); }); layer.routes_maker.map.driver.create_overlay(self); }; const update_form = () => { layer.routes_maker.map.driver.update_overalay(self); }; constructor(); }; return LayerItemModel; })();