Retour à la documentation
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/_base/array',
'spw/api/MapService',
'esri/layers/WMTSLayer',
'esri/layers/WMTSLayerInfo'
],
function(declare, lang, array, MapService, WMTSLayer, WMTSLayerInfo) {
/**
* @class spw.api.WmtsMapService
* @classdesc Service du viewer correspondant à un WMTSLayer d'ESRI
* @extends {spw.api.MapService}
*/
var WmtsMapService = declare('spw.api.WmtsMapService', [MapService], /** @lends spw.api.WmtsMapService.prototype */ {
wmtsParameters: null,
hasLegend: false,
constructor: function() {
this._propertiesToKeep.push('copyright');
this._propertiesToKeep.push('wmtsParameters');
},
/**
* Crée le layer Esri sur base de la configuration du MapService.
* @memberOf spw.api.MapService
*/
createMapLayer: function() {
this.layer = this._createWmtsLayer();
this.inherited(arguments);
},
/**
* Crée le layer Esri sur base de la configuration du MapService.
*/
_createWmtsLayer: function(options){
if (this.get('wmtsParameters')) {
if(this.get('wmtsParameters').resourceInfo) {
var layerInfos = this.get('wmtsParameters').resourceInfo.layerInfos;
array.forEach(layerInfos, function(layerInfo, idx) {
layerInfos[idx] = new WMTSLayerInfo(layerInfo);
});
}
if(this.get('wmtsParameters').layerInfo) {
this.get('wmtsParameters').layerInfo = new WMTSLayerInfo(this.get('wmtsParameters').layerInfo);
}
}
return new WMTSLayer(this.get('url'), lang.mixin(this.get('wmtsParameters'), {id: this.serviceId}));
},
/**
* Méthode appelée une fois que le layer a été chargé.
*/
layerLoaded: function(loadedEvent) {
if (this.layer.spatialReference && this.layer.spatialReference.wkid !== this.spwMap.spwViewer.get('spatialReference').wkid) {
this.layerError('Ce service n\'est pas compatible avec le système de projection du fond de plan actuel.');
return;
}
array.forEach(loadedEvent.layer.layerInfos, lang.hitch(this, function(layerInfo){
this._mergeLayerInfo(layerInfo);
}));
this._afterLayerLoaded();
}
});
return WmtsMapService;
});