tchen-vuelayers
Version:
Web map Vue components with the power of OpenLayers
164 lines (141 loc) • 4.22 kB
JavaScript
/**
* 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 _Array$from from '@babel/runtime-corejs2/core-js/array/from';
import WMTSSource from 'ol/source/WMTS';
import WMTSTileGrid from 'ol/tilegrid/WMTS';
import tileSource from '../mixin/tile-source';
import { WMTS_FORMAT, WMTS_REQUEST_ENCODING, WMTS_VERSION } from '../ol-ext/consts';
import { createExtentFromProjection } from '../ol-ext/extent';
import { resolutionsFromExtent } from '../ol-ext/tile-grid';
import { hasView } from '../util/assert';
import { range, pick } from '../util/minilo';
import _Object$assign from '@babel/runtime-corejs2/core-js/object/assign';
var props = {
dimensions: Object,
format: {
type: String,
default: WMTS_FORMAT
},
layerName: {
type: String,
required: true
},
matrixSet: {
type: String,
required: true
},
requestEncoding: {
type: String,
default: WMTS_REQUEST_ENCODING
},
styleName: {
type: String,
required: true
},
version: {
type: String,
default: WMTS_VERSION
},
url: {
type: String,
required: true
}
};
var methods = {
/**
* @returns {WMTS}
* @protected
*/
createSource: function createSource() {
return new WMTSSource({
attributions: this.attributions,
cacheSize: this.cacheSize,
crossOrigin: this.crossOrigin,
dimensions: this.dimensions,
format: this.format,
layer: this.layerName,
logo: this.logo,
matrixSet: this.matrixSet,
projection: this.projection,
reprojectionErrorThreshold: this.reprojectionErrorThreshold,
requestEncoding: this.requestEncoding,
tileGrid: this._tileGrid,
tilePixelRatio: this.tilePixelRatio,
style: this.styleName,
version: this.version,
url: this.urlTmpl,
wrapX: this.wrapX,
transition: this.transition,
tileLoadFunction: this.tileLoadFunction
});
},
/**
* @return {WMTS}
* @protected
*/
createTileGrid: function createTileGrid() {
hasView(this);
var extent = createExtentFromProjection(this.$view.getProjection());
var resolutions = resolutionsFromExtent(extent, this.maxZoom, this.tileSize);
return new WMTSTileGrid({
extent: extent,
resolutions: resolutions,
tileSize: this.tileSize,
minZoom: this.minZoom,
matrixIds: _Array$from(range(this.minZoom, resolutions.length))
});
}
};
var script = {
name: 'vl-source-wmts',
mixins: [tileSource],
props: props,
methods: methods
};
/* script */
var __vue_script__ = script;
/* template */
/* style */
var __vue_inject_styles__ = undefined;
/* scoped */
var __vue_scope_id__ = undefined;
/* module identifier */
var __vue_module_identifier__ = undefined;
/* functional template */
var __vue_is_functional_template__ = undefined;
/* component normalizer */
function __vue_normalize__(template, style, script$$1, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) {
var component = (typeof script$$1 === 'function' ? script$$1.options : script$$1) || {}; // For security concerns, we use only base name in production mode.
component.__file = "source.vue";
if (!component.render) {
component.render = template.render;
component.staticRenderFns = template.staticRenderFns;
component._compiled = true;
if (functional) component.functional = true;
}
component._scopeId = scope;
return component;
}
/* style inject */
/* style inject SSR */
var Source = __vue_normalize__({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);
function plugin(Vue) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (plugin.installed) {
return;
}
plugin.installed = true;
options = pick(options, 'dataProjection');
_Object$assign(Source, options);
Vue.component(Source.name, Source);
}
export default plugin;
export { Source, plugin as install };