Source: api/ComposedMapService.js

Retour à la documentation
define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'spw/api/MapService',
    'spw/api/MapServiceFactory'
],
function(declare, lang, MapService, MapServiceFactory) {

    /**
     * @class spw.api.ComposedMapService
     * @extends {spw.api.MapService}
     */
    var ComposedMapService = declare('spw.api.ComposedMapService', [MapService], /** @lends spw.api.ComposedMapService.prototype */{

        /**
         * Crée le layer Esri sur base de la configuration du MapService.
         * @memberOf spw.api.MapService
         */
        createMapLayer: function() {
            this.composedLayers = [];
            this.composedLayerLoading = this.services.length;

            array.forEach(this.services, lang.hitch(this, function(service) {
                this.composedLayers.push(MapServiceFactory.createService(lang.mixin(service, {
                    spwMap: this.spwMap
                })));

                if(this.composedLayers[this.composedLayers.length-1].get('loaded')){
                    if(--this.composedLayerLoading === 0){
//                      this.set('loaded', true);
//                      this.emit(this.events.MapServiceLoaded, this);
//                      this.set('hasLegend', false);
//                      this.layerLoaded({layer: this.layer});
                    }
                } else {
                    this.composedLayers[this.composedLayers.length-1].on(MapService.events.MapServiceLoaded, lang.hitch(this, function() {
                        if(--this.composedLayerLoading === 0) {
//                          this.set('loaded', true);
                            //this.emit(this.events.MapServiceLoaded, this);
//                          this.set('hasLegend', false);
                            //this.layerLoaded({layer: this.layer});
                        }
                    }));
                }
            }));
        }

    });

    return ComposedMapService;

});