Commit 3ac4fa8b authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Simplifica redimensión inicial de mapa

En lugar de escuchar contenedores de Dijit pertenecientes a sus
ancestros (que además ya no existen), se autogestiona su comprobación de
tamaño. Intenta dibujarse hasta que lo consigue, cuando tiene tamaño
válido para poder hacerlo.
parent 63b9c7ea
Loading
Loading
Loading
Loading
+17 −19
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ define([
				measureTools: true,
				queryableClass: "leaflet-queryable",

				_mapNodeValidSizeInterval: 100,

				layerTypes: {
					base: "base",
					forced: "forced",
@@ -174,34 +176,30 @@ define([

		_afterShow: function() {

			var containerNode = this.mapParentNode.parentNode,
				containerId = containerNode.id,
				containerWidget = containerId ? registry.byId(containerId) : null,
				dfd = new Deferred();
			var dfd = new Deferred();

			if (!this._getPreviouslyShown()) {
				dfd.then(lang.hitch(this, this._addMapWidgets));
			}

			if (containerWidget) {
				if (!this._getPreviouslyShown()) {
			dfd.then(lang.hitch(this, this._onMapNodeValidSize));

					aspect.after(containerWidget, "resize", lang.hitch(this, function(dfd) {
			this._mapNodeValidSizeIntervalHandler = setInterval(lang.hitch(this, function(dfd) {

						this.invalidateSize();
						dfd.resolve();
					}, dfd));
				} else {
					dfd.resolve();
				}
			} else {
				this.invalidateSize();
				if (this.mapParentNode.clientHeight) {
					clearInterval(this._mapNodeValidSizeIntervalHandler);
					dfd.resolve();
				}
			}, dfd), this._mapNodeValidSizeInterval);

			return dfd;
		},

		_onMapNodeValidSize: function() {

			if (!this._getPreviouslyShown()) {
				this._addMapWidgets();
			}

			this.invalidateSize();
		},

		_addMapWidgets: function() {

			this._addCoordinatesViewer();