Commit d1e7f615 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'feature-AddDefaultGlobalBasemap' into 'dev'

Feature add default global basemap

See merge request redmic-project/client/web!49
parents 3c737700 3a34ad96
Loading
Loading
Loading
Loading
+39 −26
Original line number Diff line number Diff line
@@ -2,62 +2,75 @@ define({
	//	summary:
	//		Definiciones de capas base para los mapas de Leaflet.
	//	description:
	//		Contiene la definición de las capas base para heredarse e instanciarlas desde el widget OpenLayers.
	//		Contiene la definición de las capas base para instanciarlas desde OpenLayers.

	"topografico": {
		type: "wmts",
		url: "https://idecan3.grafcan.es/ServicioWMS/MTI",
	'topografico': {
		type: 'wmts',
		url: 'https://{s}.grafcan.es/ServicioWMS/MTI',
		props: {
			layers: 'WMS_MTI',
			format: 'image/png',
			//subdomains: ['2', '3'],
			subdomains: ['idecan2', 'idecan3'],
			uppercase: true,
			attribution: "GrafCan",
			attribution: '<a href="https://www.grafcan.es" target="_blank" title="GRAFCAN">GRAFCAN</a>',
			minZoom: 5,
			maxZoom: 21,
			tiled: true
		}
	},

	"ortofoto": {
		type: "wmts",
		url: "https://idecan3.grafcan.es/ServicioWMS/OrtoUrb_bat",
	'ortofoto': {
		type: 'wmts',
		url: 'https://{s}.grafcan.es/ServicioWMS/OrtoUrb_bat',
		props: {
			layers: 'WMS_OrtoExpressUrb',
			format: 'image/jpeg',
			uppercase: true,
			//subdomains: ['1', '3'],
			attribution: "GrafCan",
			subdomains: ['idecan3'],
			attribution: '<a href="https://www.grafcan.es" target="_blank" title="GRAFCAN">GRAFCAN</a>',
			minZoom: 5,
			maxZoom: 21,
			tiled: true
		}
	},

	"redmic": {
		type: "wmts",
		url: "https://atlas.redmic.es/geoserver/basemap/wms",
	'redmic': {
		type: 'wmts',
		url: 'https://atlas.redmic.es/geoserver/basemap/wms',
		props: {
			layers: 'Redmic',
			format: 'image/jpeg',
			uppercase: true,
			//subdomains: ['1', '3'],
			attribution: '<a href="http://www.oag-fundacion.org/" target="_blank" title="Observatorio Ambiental Granadilla">OAG</a>',
			attribution: '<a href="http://www.oag-fundacion.org" target="_blank" title="Observatorio Ambiental Granadilla">OAG</a>',
			minZoom: 1,
			maxZoom: 18,
			tiled: true
		}
	}/*,
	},

	"redmic": {
		type: "wms",
		url: "https://atlas.redmic.es/Basemap/gwc/service/wms",
	'eoc-map': {
		type: 'tileLayer',
		url: 'https://tiles.geoservice.dlr.de/service/tms/1.0.0/{layers}@{crs}@{format}/{z}/{x}/{-y}.{format}',
		props: {
			layers: "Basemap:basemapOceano",
			format: 'image/jpeg',
			attribution: '<a href="http://www.oag-fundacion.org/" target="_blank" title="Observatorio Ambiental Granadilla">OAG</a>',
			minZoom: 5,
			maxZoom: 18
			layers: 'eoc:basemap',
			crs: 'EPSG:4326',
			format: 'png',
			attribution: '<a href="https://geoservice.dlr.de" target="_blank" title="Earth Observation Center (EOC) of the German Aerospace Center (DLR)">EOC Geoservice</a>',
			minZoom: 1,
			maxZoom: 15
		}
	},

	'eoc-overlay': {
		type: 'tileLayer',
		url: 'https://tiles.geoservice.dlr.de/service/tms/1.0.0/{layers}@{crs}@{format}/{z}/{x}/{-y}.{format}',
		props: {
			layers: 'eoc:baseoverlay',
			crs: 'EPSG:4326',
			format: 'png',
			attribution: '<a href="https://geoservice.dlr.de" target="_blank" title="Earth Observation Center (EOC) of the German Aerospace Center (DLR)">EOC Geoservice</a>',
			minZoom: 1,
			maxZoom: 15
		}
	}
	}*/
});
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ define({
		redmic: "REDMIC",
		topografico: "Topographic",
		ortofoto: "Orthophoto",
		"eoc-map": "World",

		zec: "ZEC",
		batimetrias: "Bathymetry",
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ define({
	redmic: "REDMIC",
	topografico: "Topográfico",
	ortofoto: "Ortofoto",
	"eoc-map": "Mundial",

	zec: "ZEC",
	batimetrias: "Batimetrías",
+9 −3
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ define([
				doubleClickZoom: false,
				minZoom: this.minZoom,
				maxZoom: this.maxZoom,
				attributionControl: false,
				attributionControl: true,
				worldCopyJump: true
			});
			this.map.once("load", lang.hitch(this, this._afterMapLoaded));
@@ -251,7 +251,13 @@ define([
				return;
			}

			var baseMap = OpenLayers.get(this.defaultBaseLayer).instance,
			var defaultLayerName = this.baseLayers[this.defaultBaseLayer];

			if (defaultLayerName instanceof Array) {
				defaultLayerName = defaultLayerName[0];
			}

			var baseMap = OpenLayers.get(defaultLayerName).instance,
				miniMapConfig = {
					position: "topright",
					collapsedWidth: 36,
@@ -267,7 +273,7 @@ define([

			miniMap.addTo(this.map);

			// Workaround for https://github.com/Norkart/Leaflet-MiniMap/issues/114
			// TODO workaround for https://github.com/Norkart/Leaflet-MiniMap/issues/114
			on(miniMap._miniMap._container, "click", function(evt) { evt.stopPropagation(); });
		},

+78 −50
Original line number Diff line number Diff line
@@ -92,7 +92,13 @@ define([

				ownChannel: "map",

				defaultBaseLayer: "ortofoto"
				baseLayers: [
					['eoc-map', 'eoc-overlay'],
					'topografico',
					'ortofoto'
				],
				defaultBaseLayer: 0,
				_relatedBaseLayers: {}
			};

			lang.mixin(this, this.config, args);
@@ -231,87 +237,100 @@ define([
			});
		},

		_changeBaseLayer: function(layer) {
		_changeBaseLayer: function(layer, layerGroup) {

			var layerId,
			var layerInstance,
				layerLabel;

			if (typeof layer !== "object") {
			if (typeof layer === "object" && layer instanceof Array) {
				for (var i = 0; i < layer.length; i++) {
					this._changeBaseLayer(layer[i], layer);
				}
			} else {
				if (!(layer && layer.length)) {
					this._emitEvt('BASE_LAYER_CHANGE_FAIL', layer);
					return;
				}

				layerId = layer;
				layerObj = OpenLayers.get(layer);
				layer = layerObj.instance;
				var layerIsGroupLeader = layerGroup && layerGroup.indexOf(layer) === 0;

				if (layerIsGroupLeader) {
					this._relatedBaseLayers[layer] = layerGroup;
				}

				var layerObj = OpenLayers.get(layer);
				layerInstance = layerObj.instance;
				if (layerGroup && !layerIsGroupLeader) {
					layerLabel = '';
				} else {
					layerLabel = layerObj.label;
				}
			}

			if (!layer) {
				this._emitEvt('BASE_LAYER_CHANGE_FAIL', layerId);
			if (!layerInstance) {
				this._emitEvt('BASE_LAYER_CHANGE_FAIL', layer);
				return;
			}

			this._cleanBaseLayers(layer);
			this._addBaseLayer(layer, layerId, layerLabel);
			this._cleanBaseLayers(layerInstance, layerGroup);
			this._addBaseLayer(layerInstance, layer, layerLabel);
		},

		_cleanBaseLayers: function(layer) {
		_cleanBaseLayers: function(layer, layerGroup) {
			// Limpiamos del mapa todas las capas base que no sean la nueva (si estuviera)

			for (var key in this.layers) {
				if (layerGroup && layerGroup.indexOf(key) !== -1) {
					continue;
				}

				var layerObj = this.layers[key];

				if (this._isBaseLayer(layerObj)) {
					var baseLayer = layerObj.layer;
					if (this.hasLayer(baseLayer) && baseLayer != layer) {
						this.removeLayer(baseLayer);
				if (!layerObj || !this._isBaseLayer(layerObj)) {
					continue;
				}

				var mapLayer = layerObj.layer;
				if (this.hasLayer(mapLayer) && mapLayer !== layer) {
					this.removeLayer(mapLayer);
				}
			}
		},

		_isBaseLayer: function(layerObj) {

			if (layerObj.type === this.layerTypes.base) {
				return true;
			}

			return false;
			return layerObj.type === this.layerTypes.base;
		},

		_isForcedLayer: function(layerObj) {

			if (layerObj.type === this.layerTypes.forced) {
				return true;
			}

			return false;
			return layerObj.type === this.layerTypes.forced;
		},

		_isOptionalLayer: function(layerObj) {

			if (layerObj.type === this.layerTypes.optional) {
				return true;
			}

			return false;
			return layerObj.type === this.layerTypes.optional;
		},

		_addBaseLayer: function(layer, layerId, layerLabel) {
		_addBaseLayer: function(layerInstance, layerId, layerLabel) {

			if (!this._existsBaseLayer(layerId)) {
				this.layers[layerId] = {
					layer: layer,
					layer: layerInstance,
					type: this.layerTypes.base,
					order: 1
				};
				this.addLayer(layer, layerId);
				this.controlLayers.addBaseLayer(layer, layerLabel);
				this.addLayer(layerInstance, layerId);
				this.controlLayers.addBaseLayer(layerInstance, layerLabel);
			} else {
				var previousBaseLayer = this._getExistingBaseLayer(layerId);
				if (previousBaseLayer) {
					this.addLayer(previousBaseLayer);
				} else {
				this.addLayer(this._getExistingBaseLayer(layerId, layer));
				this._emitEvt('BASE_LAYER_CHANGE', layer);
					// Se buscaba una baselayer que no existia anteriormente
					// TODO esto no debería publicar un BASE_LAYER_CHANGE_FAIL??
					this._emitEvt('BASE_LAYER_CHANGE', layerInstance);
				}
			}
		},

@@ -324,7 +343,11 @@ define([
			return false;
		},

		_getExistingBaseLayer: function(layerId, layer) {
		_getExistingBaseLayer: function(layerId) {

			if (!this.controlLayers) {
				return;
			}

			var previousBaseLayers = this.controlLayers._layers;

@@ -335,9 +358,6 @@ define([
					return baseLayer;
				}
			}

			// Se buscaba una baselayer que no existia anteriormente
			this._emitEvt('BASE_LAYER_CHANGE', layer);
		},

		_subAddLayer: function(obj) {
@@ -656,7 +676,15 @@ define([

		_pubBaseLayerChanged: function(channel, baseLayer) {

			this.bringLayerToBack(baseLayer.layer ? baseLayer.layer : baseLayer);
			var layerInstance = baseLayer.layer || baseLayer,
				layerId = layerInstance._leaflet_id,
				relatedLayerIds = this._relatedBaseLayers[layerId];

			if (relatedLayerIds) {
				this._changeBaseLayer(relatedLayerIds);
			}

			this.bringLayerToBack(layerInstance);

			this._publish(channel, {
				success: true,
@@ -724,18 +752,18 @@ define([

		_afterMapLoaded: function() {

			// TODO revisar las capas base
			//this._changeBaseLayer(this.defaultBaseLayer);
			this._changeBaseLayer("topografico");
			this._changeBaseLayer("ortofoto");
			//this._changeBaseLayer(this.defaultBaseLayer);
			for (var i = 0; i < this.baseLayers.length; i++) {
				var baseLayer = this.baseLayers[i];
				this._changeBaseLayer(baseLayer);
			}
			this._changeBaseLayer(this.baseLayers[this.defaultBaseLayer]);
			this._addContainerListeners();
		},

		clear: function() {

			this._clearLayers();
			this._changeBaseLayer(this.defaultBaseLayer);
			this._changeBaseLayer(this.baseLayers[this.defaultBaseLayer]);
			this._resetMapPosition();
		},

Loading