Loading client-app/src/component/map/layer/TrackingLayerImpl.js +23 −40 Original line number Diff line number Diff line Loading @@ -56,8 +56,6 @@ define([ GO_TO_POSITION: 'goToPosition', SHOW_DIRECTION_MARKERS: 'showDirectionMarkers', HIDE_DIRECTION_MARKERS: 'hideDirectionMarkers', ZOOM_SET: 'zoomSet', ZOOM_START: 'zoomStart', DATA_BOUNDS_UPDATED: 'dataBoundsUpdated' } }; Loading Loading @@ -106,14 +104,6 @@ define([ }; this.subscriptionsConfig.push({ channel: this._buildChannel(this.mapChannel, this.actions.ZOOM_START), callback: '_subZoomStart', options: options },{ channel: this._buildChannel(this.mapChannel, this.actions.ZOOM_SET), callback: '_subZoomSet', options: options },{ channel: this.getChannel('GO_TO_POSITION'), callback: '_subGoToPosition', options: options Loading @@ -131,13 +121,6 @@ define([ this._pathGenerator = this._getGeoPath(); }, _getLatLng: function(lat, lng) { if (lat && lng) { return new L.latLng(lat, lng); } }, _afterLayerAdded: function() { if (!this._svg) { Loading @@ -156,9 +139,26 @@ define([ _afterLayerRemoved: function() { //this.clear(); this._clear(); }, _clear: function() { this._svg.remove(); this._svg = null; Object.keys(this._trackingLineInstances).forEach((featureId) => { const lineInstance = this._trackingLineInstances[featureId], lineOwnChannel = lineInstance.getOwnChannel(); this._publish(lineInstance.getChannel('DESTROY')); delete this._trackingLineInstances[featureId]; delete this._trackingLineInstancesByChannel[lineOwnChannel]; delete this._subsToLines[lineOwnChannel]; delete this._pubsToLines[lineOwnChannel]; }); }, _createEventListeners: function() { Loading Loading @@ -259,10 +259,7 @@ define([ _getFeatureId: function(feature) { var props = feature && feature.properties, element = props && props[this._elementPropName]; return element && element[this._elementIdPropName]; return feature?.properties?.[this._elementPropName]?.[this._elementIdPropName]; }, _createTrackingLine: function() { Loading Loading @@ -374,12 +371,6 @@ define([ } }, _subZoomStart: function(res) { // TODO unificar con listenZoom this._onZoomStart(res); }, _onZoomStart: function(res) { this._emitEvt('LAYER_LOADING'); Loading @@ -387,19 +378,11 @@ define([ this._removeHoverEffects(); }, _subZoomSet: function(res) { // TODO unificar con listenZoom this._onZoomSet(res); }, _onZoomSet: function(res) { _onZoomSet: function(zoom, res) { this._emitEvt('ADD_TO_QUERY', { query: { this._redraw({ terms: { zoomLevel: res.zoom } zoomLevel: zoom } }); }, Loading client-app/src/component/map/layer/TrackingLine.js +0 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ define([ , 'dojo/Deferred' , 'dojo/mouse' , 'dojo/on' , 'leaflet' , 'src/component/base/_Module' , 'src/component/map/layer/_TrackingDataManagement' , 'src/component/map/layer/_TrackingMarkersManagement' Loading @@ -17,7 +16,6 @@ define([ , Deferred , mouse , on , L , _Module , _TrackingDataManagement , _TrackingMarkersManagement Loading client-app/src/component/map/layer/_ListenZoom.js +75 −13 Original line number Diff line number Diff line Loading @@ -8,6 +8,16 @@ define([ , Utilities ) { const defaultConfig = { actions: { ZOOM_START: 'zoomStart', ZOOM_SET: 'zoomSet', GET_ZOOM: 'getZoom', GOT_ZOOM: 'gotZoom' }, minZoom: 0 }; return declare(null, { // summary: // Extensión de MapLayer para que escuche los cambios de zoom del mapa. Loading @@ -15,44 +25,96 @@ define([ // Permite escuchar los cambios de zoom directamente desde el módulo del mapa y recibir un zoom mínimo // para limitar su aparición en el mapa. constructor: function(args) { postMixInProperties: function() { const defaultConfig = { actions: { ZOOM_SET: 'zoomSet' this._mergeOwnAttributes(defaultConfig); this.inherited(arguments); }, minZoom: 0, _currentZoom: 7 }; lang.mixin(this, this._merge([this, defaultConfig, args])); postCreate: function() { this.inherited(arguments); this._getCurrentZoom(); }, _defineSubscriptions: function() { this.inherited(arguments); const options = { predicate: lang.hitch(this, this._chkLayerAdded) }; this.subscriptionsConfig.push({ channel : this._buildChannel(this.mapChannel, 'GOT_ZOOM'), callback: '_subGotZoom' },{ channel : this._buildChannel(this.mapChannel, 'ZOOM_START'), callback: '_subZoomStart', options },{ channel : this._buildChannel(this.mapChannel, 'ZOOM_SET'), callback: '_subZoomSet' callback: '_subZoomSet', options }); }, _getCurrentZoom: function() { this._publish(this._buildChannel(this.mapChannel, 'GET_ZOOM')); }, _subGotZoom: function(res) { this._applyZoomLevel(res); }, _subZoomStart: function(res) { this._onZoomStart?.(res); }, _subZoomSet: function(res) { this._applyZoomLevel(res); }, _applyZoomLevel: function(res) { this._currentZoom = res.zoom; this._onZoomSet?.(this._currentZoom, res); }, _afterLayerAdded: function() { this.inherited(arguments); if (!this._currentZoomIsValid()) { this.clear(); } }, _onMinZoomPropSet: function() { if (!this._currentZoomIsValid()) { this.clear(); } }, _onMinZoomPropSet: function(changeObj) { _currentZoomIsValid: function() { return Utilities.isValidNumber(this.minZoom) && Utilities.isValidNumber(this._currentZoom) && this.minZoom <= this._currentZoom; }, _shouldAbortRequest: function(params) { var originalReturn = this.inherited(arguments); return originalReturn || (Utilities.isValidNumber(this.minZoom) && Utilities.isValidNumber(this._currentZoom) && this.minZoom > this._currentZoom); return originalReturn || !this._currentZoomIsValid(); } }); }); client-app/src/component/map/layer/_RequestData.js 0 → 100644 +71 −0 Original line number Diff line number Diff line define([ "dojo/_base/declare" , "dojo/_base/lang" ], function( declare , lang ) { return declare(null, { // summary: // Extensión para realizar consultas de datos desde una capa. postCreate: function() { this.inherited(arguments); this._redraw(); }, _redraw: function(queryObj) { // TODO realmente se quiere evitar límites? puede causar fallos en el lado del servicio // preferible mostrar aviso si se llega al límite const query = queryObj ?? {size: null}; this._emitEvt('ADD_REQUEST_PARAMS', { target: this.target, params: { query } }); if (this._shouldAbortRequest()) { this._emitEvt('LAYER_LOADED'); return; } clearTimeout(this.timeoutRedrawHandler); this.timeoutRedrawHandler = setTimeout(lang.hitch(this, this._redrawRequestData), 100); }, _redrawRequestData: function() { this._emitEvt('LAYER_LOADING'); const path = this.targetPathParams ?? {}; this._emitEvt('REQUEST', { method: 'POST', target: this.target, action: '_search', params: {path}, requesterId: this.getOwnChannel() }); }, _shouldAbortRequest: function() { var originalReturn = this.inherited(arguments); return originalReturn || !this.target || !!this.externalShouldAbortRequest?.(); }, _onTargetPropSet: function() { this.inherited(arguments); this._redraw(); } }); }); client-app/src/oldapp/designs/mapWithSideContent/main/Tracking.js +5 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,8 @@ define([ , 'src/component/form/FormContainerImpl' , 'src/component/layout/genericDisplayer/GenericWithTopbarDisplayerImpl' , 'src/component/layout/TabsDisplayer' , "src/component/map/layer/_AddFilter" , "src/component/map/layer/_RequestData" , "src/component/map/layer/_ListenZoom" , "src/component/map/layer/_PublishInfo" , "src/component/map/layer/TrackingLayerImpl" , "src/component/mapQuery/QueryOnMap" Loading @@ -36,7 +37,8 @@ define([ , FormContainerImpl , GenericWithTopbarDisplayerImpl , TabsDisplayer , _AddFilter , _RequestData , _ListenZoom , _PublishInfo , TrackingLayerImpl , QueryOnMap Loading Loading @@ -128,7 +130,7 @@ define([ _initializeMain: function() { this.TrackingClusterLayer = declare([TrackingLayerImpl, _AddFilter, _PublishInfo]); this.TrackingClusterLayer = declare([TrackingLayerImpl, _RequestData, _PublishInfo, _ListenZoom]); this.progressSlider = new ProgressSlider({ parentChannel: this.getChannel(), Loading Loading
client-app/src/component/map/layer/TrackingLayerImpl.js +23 −40 Original line number Diff line number Diff line Loading @@ -56,8 +56,6 @@ define([ GO_TO_POSITION: 'goToPosition', SHOW_DIRECTION_MARKERS: 'showDirectionMarkers', HIDE_DIRECTION_MARKERS: 'hideDirectionMarkers', ZOOM_SET: 'zoomSet', ZOOM_START: 'zoomStart', DATA_BOUNDS_UPDATED: 'dataBoundsUpdated' } }; Loading Loading @@ -106,14 +104,6 @@ define([ }; this.subscriptionsConfig.push({ channel: this._buildChannel(this.mapChannel, this.actions.ZOOM_START), callback: '_subZoomStart', options: options },{ channel: this._buildChannel(this.mapChannel, this.actions.ZOOM_SET), callback: '_subZoomSet', options: options },{ channel: this.getChannel('GO_TO_POSITION'), callback: '_subGoToPosition', options: options Loading @@ -131,13 +121,6 @@ define([ this._pathGenerator = this._getGeoPath(); }, _getLatLng: function(lat, lng) { if (lat && lng) { return new L.latLng(lat, lng); } }, _afterLayerAdded: function() { if (!this._svg) { Loading @@ -156,9 +139,26 @@ define([ _afterLayerRemoved: function() { //this.clear(); this._clear(); }, _clear: function() { this._svg.remove(); this._svg = null; Object.keys(this._trackingLineInstances).forEach((featureId) => { const lineInstance = this._trackingLineInstances[featureId], lineOwnChannel = lineInstance.getOwnChannel(); this._publish(lineInstance.getChannel('DESTROY')); delete this._trackingLineInstances[featureId]; delete this._trackingLineInstancesByChannel[lineOwnChannel]; delete this._subsToLines[lineOwnChannel]; delete this._pubsToLines[lineOwnChannel]; }); }, _createEventListeners: function() { Loading Loading @@ -259,10 +259,7 @@ define([ _getFeatureId: function(feature) { var props = feature && feature.properties, element = props && props[this._elementPropName]; return element && element[this._elementIdPropName]; return feature?.properties?.[this._elementPropName]?.[this._elementIdPropName]; }, _createTrackingLine: function() { Loading Loading @@ -374,12 +371,6 @@ define([ } }, _subZoomStart: function(res) { // TODO unificar con listenZoom this._onZoomStart(res); }, _onZoomStart: function(res) { this._emitEvt('LAYER_LOADING'); Loading @@ -387,19 +378,11 @@ define([ this._removeHoverEffects(); }, _subZoomSet: function(res) { // TODO unificar con listenZoom this._onZoomSet(res); }, _onZoomSet: function(res) { _onZoomSet: function(zoom, res) { this._emitEvt('ADD_TO_QUERY', { query: { this._redraw({ terms: { zoomLevel: res.zoom } zoomLevel: zoom } }); }, Loading
client-app/src/component/map/layer/TrackingLine.js +0 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ define([ , 'dojo/Deferred' , 'dojo/mouse' , 'dojo/on' , 'leaflet' , 'src/component/base/_Module' , 'src/component/map/layer/_TrackingDataManagement' , 'src/component/map/layer/_TrackingMarkersManagement' Loading @@ -17,7 +16,6 @@ define([ , Deferred , mouse , on , L , _Module , _TrackingDataManagement , _TrackingMarkersManagement Loading
client-app/src/component/map/layer/_ListenZoom.js +75 −13 Original line number Diff line number Diff line Loading @@ -8,6 +8,16 @@ define([ , Utilities ) { const defaultConfig = { actions: { ZOOM_START: 'zoomStart', ZOOM_SET: 'zoomSet', GET_ZOOM: 'getZoom', GOT_ZOOM: 'gotZoom' }, minZoom: 0 }; return declare(null, { // summary: // Extensión de MapLayer para que escuche los cambios de zoom del mapa. Loading @@ -15,44 +25,96 @@ define([ // Permite escuchar los cambios de zoom directamente desde el módulo del mapa y recibir un zoom mínimo // para limitar su aparición en el mapa. constructor: function(args) { postMixInProperties: function() { const defaultConfig = { actions: { ZOOM_SET: 'zoomSet' this._mergeOwnAttributes(defaultConfig); this.inherited(arguments); }, minZoom: 0, _currentZoom: 7 }; lang.mixin(this, this._merge([this, defaultConfig, args])); postCreate: function() { this.inherited(arguments); this._getCurrentZoom(); }, _defineSubscriptions: function() { this.inherited(arguments); const options = { predicate: lang.hitch(this, this._chkLayerAdded) }; this.subscriptionsConfig.push({ channel : this._buildChannel(this.mapChannel, 'GOT_ZOOM'), callback: '_subGotZoom' },{ channel : this._buildChannel(this.mapChannel, 'ZOOM_START'), callback: '_subZoomStart', options },{ channel : this._buildChannel(this.mapChannel, 'ZOOM_SET'), callback: '_subZoomSet' callback: '_subZoomSet', options }); }, _getCurrentZoom: function() { this._publish(this._buildChannel(this.mapChannel, 'GET_ZOOM')); }, _subGotZoom: function(res) { this._applyZoomLevel(res); }, _subZoomStart: function(res) { this._onZoomStart?.(res); }, _subZoomSet: function(res) { this._applyZoomLevel(res); }, _applyZoomLevel: function(res) { this._currentZoom = res.zoom; this._onZoomSet?.(this._currentZoom, res); }, _afterLayerAdded: function() { this.inherited(arguments); if (!this._currentZoomIsValid()) { this.clear(); } }, _onMinZoomPropSet: function() { if (!this._currentZoomIsValid()) { this.clear(); } }, _onMinZoomPropSet: function(changeObj) { _currentZoomIsValid: function() { return Utilities.isValidNumber(this.minZoom) && Utilities.isValidNumber(this._currentZoom) && this.minZoom <= this._currentZoom; }, _shouldAbortRequest: function(params) { var originalReturn = this.inherited(arguments); return originalReturn || (Utilities.isValidNumber(this.minZoom) && Utilities.isValidNumber(this._currentZoom) && this.minZoom > this._currentZoom); return originalReturn || !this._currentZoomIsValid(); } }); });
client-app/src/component/map/layer/_RequestData.js 0 → 100644 +71 −0 Original line number Diff line number Diff line define([ "dojo/_base/declare" , "dojo/_base/lang" ], function( declare , lang ) { return declare(null, { // summary: // Extensión para realizar consultas de datos desde una capa. postCreate: function() { this.inherited(arguments); this._redraw(); }, _redraw: function(queryObj) { // TODO realmente se quiere evitar límites? puede causar fallos en el lado del servicio // preferible mostrar aviso si se llega al límite const query = queryObj ?? {size: null}; this._emitEvt('ADD_REQUEST_PARAMS', { target: this.target, params: { query } }); if (this._shouldAbortRequest()) { this._emitEvt('LAYER_LOADED'); return; } clearTimeout(this.timeoutRedrawHandler); this.timeoutRedrawHandler = setTimeout(lang.hitch(this, this._redrawRequestData), 100); }, _redrawRequestData: function() { this._emitEvt('LAYER_LOADING'); const path = this.targetPathParams ?? {}; this._emitEvt('REQUEST', { method: 'POST', target: this.target, action: '_search', params: {path}, requesterId: this.getOwnChannel() }); }, _shouldAbortRequest: function() { var originalReturn = this.inherited(arguments); return originalReturn || !this.target || !!this.externalShouldAbortRequest?.(); }, _onTargetPropSet: function() { this.inherited(arguments); this._redraw(); } }); });
client-app/src/oldapp/designs/mapWithSideContent/main/Tracking.js +5 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,8 @@ define([ , 'src/component/form/FormContainerImpl' , 'src/component/layout/genericDisplayer/GenericWithTopbarDisplayerImpl' , 'src/component/layout/TabsDisplayer' , "src/component/map/layer/_AddFilter" , "src/component/map/layer/_RequestData" , "src/component/map/layer/_ListenZoom" , "src/component/map/layer/_PublishInfo" , "src/component/map/layer/TrackingLayerImpl" , "src/component/mapQuery/QueryOnMap" Loading @@ -36,7 +37,8 @@ define([ , FormContainerImpl , GenericWithTopbarDisplayerImpl , TabsDisplayer , _AddFilter , _RequestData , _ListenZoom , _PublishInfo , TrackingLayerImpl , QueryOnMap Loading Loading @@ -128,7 +130,7 @@ define([ _initializeMain: function() { this.TrackingClusterLayer = declare([TrackingLayerImpl, _AddFilter, _PublishInfo]); this.TrackingClusterLayer = declare([TrackingLayerImpl, _RequestData, _PublishInfo, _ListenZoom]); this.progressSlider = new ProgressSlider({ parentChannel: this.getChannel(), Loading