UNPKG

tchen-vuelayers

Version:

Web map Vue components with the power of OpenLayers

80 lines (69 loc) 1.52 kB
/** * VueLayers * Web map Vue components with the power of OpenLayers * * @package vuelayers * @author Vladimir Vershinin <ghettovoice@gmail.com> * @version 0.11.1 * @license MIT * @copyright (c) 2017-2019, Vladimir Vershinin <ghettovoice@gmail.com> */ import Vue from 'vue'; var methods = { /** * @return {{ * setSource: function(Source): void, * getSource: function(): Source * }|undefined} * @protected */ getSourceTarget: function getSourceTarget() { throw new Error('Not implemented method'); }, /** * @return {Source|undefined} */ getSource: function getSource() { return this._source; }, /** * @returns {Object} * @protected */ getServices: function getServices() { var vm = this; return { get sourceContainer() { return vm; } }; }, /** * @param {Source|Vue|undefined} source * @return {void} */ setSource: function setSource(source) { source = source instanceof Vue ? source.$source : source; if (source !== this._source) { this._source = source; } /** * @type {Layer|Builder} */ var sourceTarget = this.getSourceTarget(); if (sourceTarget && source !== sourceTarget.getSource()) { sourceTarget.setSource(source); } } }; var sourceContainer = { methods: methods, created: function created() { /** * @type {Source|undefined} * @private */ this._source = undefined; } }; export default sourceContainer;