|
48 | 48 |
|
49 | 49 | initialize: function() { |
50 | 50 |
|
51 | | - this.model.on('change:lonlat',this.update,this); |
| 51 | + this.model.on('change:responseExpected',this.update,this); |
| 52 | + this.model.on('change:lonlat',this.updateLonLat,this); |
52 | 53 | this.model.on('change:responses',this.update,this); |
53 | 54 |
|
54 | 55 | }, |
|
68 | 69 |
|
69 | 70 | onClose: function() {}, |
70 | 71 |
|
71 | | - update: function() { |
72 | | - |
73 | | - // local utilities |
| 72 | + updateLonLat: function() { |
74 | 73 |
|
75 | 74 | function dec2dg(v,neg,pos){ |
76 | 75 | var tmp = v; |
|
82 | 81 | return dg+'° '+mn+'′ '+tmp.toFixed(2)+'″ '+ltr; |
83 | 82 | } |
84 | 83 |
|
| 84 | + // update click location |
| 85 | + var ll = this.model.get('lonlat') ; |
| 86 | + $('#layer-info-location-lon').html( ll ? dec2dg(ll.lon,'W','E') : 'n/a' ); |
| 87 | + $('#layer-info-location-lat').html( ll ? dec2dg(ll.lat,'S','N') : 'n/a' ); |
| 88 | + }, |
| 89 | + |
| 90 | + update: function() { |
| 91 | + |
85 | 92 | function getFirstValidResp( list ){ |
86 | 93 | for ( var i = 0 ; i < list.length ; ++i ) { |
87 | 94 | if ( list[i].data ) { return list[i] ; } |
|
90 | 97 | } |
91 | 98 |
|
92 | 99 | // update the view |
| 100 | + var inProgress = this.model.get('responseExpected'); |
| 101 | + var products = this.model.get('products'); |
| 102 | + var response = getFirstValidResp( this.model.get('responses') ); |
93 | 103 |
|
94 | | - // click location |
95 | | - var ll = this.model.get('lonlat') ; |
96 | | - $('#layer-info-location-lon').html( ll ? dec2dg(ll.lon,'W','E') : 'n/a' ); |
97 | | - $('#layer-info-location-lat').html( ll ? dec2dg(ll.lat,'S','N') : 'n/a' ); |
98 | | - |
99 | | - // content |
100 | | - var prds = this.model.get('products'); |
101 | | - var rsp = getFirstValidResp( this.model.get('responses') ); |
| 104 | + // abort update if no valid response received yet |
| 105 | + if ( inProgress && !response ) { $('#layer-info-view-alert').html("Query in progress ...") ; return ; } |
102 | 106 |
|
103 | 107 | var msg_common = "<br>Clict on the map to update this view." |
104 | | - var msg = ( rsp ? '' : ( prds.length > 0 ? 'No feature has been selected.' : |
| 108 | + var msg = ( response ? '' : ( products.length > 0 ? 'No feature has been selected.' : |
105 | 109 | 'There is no layer selected.<br>Select one in the <strong>Layers</strong> overlay.')+msg_common); |
106 | 110 |
|
107 | 111 | $('#layer-info-view-alert').html(msg) |
108 | 112 |
|
109 | | - $('#layer-info-layer-name').html( rsp ? rsp.info.name : "n/a"); |
110 | | - $('#layer-info-layer-descr').html( rsp ? rsp.info.description : "n/a"); |
| 113 | + $('#layer-info-layer-name').html( response ? response.info.name : "n/a"); |
| 114 | + $('#layer-info-layer-descr').html( response ? response.info.description : "n/a"); |
111 | 115 |
|
112 | 116 | // display layer's overlay |
113 | | - if ( !rsp && prds.length == 0 ) { |
| 117 | + if ( !response && products.length == 0 ) { |
114 | 118 | Communicator.mediator.trigger('ui:open:layercontrol'); |
115 | 119 | } |
116 | 120 |
|
117 | 121 | var frame = $('#layer-info-frame') ; |
118 | 122 |
|
119 | | - if ( rsp && rsp.protocol == 'WMS' && rsp.request.type == 'GET' ) { |
| 123 | + if ( response && response.protocol == 'WMS' && response.request.type == 'GET' ) { |
120 | 124 | frame.css('display','block'); |
121 | | - //frame.attr('src',rsp.request.url); |
122 | | - frame.attr('srcdoc',rsp.data); // HTML5 feature |
| 125 | + frame.attr('srcdoc',response.data); // HTML5 feature - overides 'src' attribute when supported by the browser |
| 126 | + frame.attr('src',response.request.url); |
123 | 127 | } else { |
124 | 128 | frame.css('display','none'); |
125 | | - frame.attr('srcdoc',''); |
126 | | - frame.attr('src','about:blank'); |
| 129 | + frame.removeAttr('srcdoc'); |
| 130 | + frame.removeAttr('src') |
127 | 131 | } |
128 | 132 |
|
129 | 133 | }, |
|
0 commit comments