Changeset 1225
- Timestamp:
- 10/16/08 16:01:29 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/camptocamp/MapFishAeai/client/mfbase/mapfish/widgets/recenter/Ws.js
r1187 r1225 27 27 /** 28 28 * Class: mapfish.widgets.WsRecenter 29 * Display a list of elements corresponding to the user input and recenters (and zooms if asked) on the selected element. 29 * Display a list of elements corresponding to the user input and recenters (and 30 * zooms if asked) on the selected element. 30 31 * 31 32 * config example: … … 36 37 * map: projectid.map.map, 37 38 * wsRecenterServices: [ 38 * {id: 'swissnames', label: 'Swissnames', url: projectid.config.wsRecenterSwissnamesUrl, urlSuffixGeo: 'features', paramIdGeo: 'ids', urlSuffixList: 'properties', paramList: 'return=id,name', listFields: ['id', 'name'], isDefault: true}, 39 * {id: 'communes', label: 'Communes', url: projectid.config.wsRecenterCommunesUrl, urlSuffixGeo: 'features', paramIdGeo: 'ids', urlSuffixList: 'properties', paramList: 'return=id,name', listFields: ['id', 'name']} 39 * {id: 'swissnames', 40 * label: 'Swissnames', 41 * url: projectid.config.wsRecenterSwissnamesUrl, 42 * urlSuffixGeo: 'features', 43 * paramIdGeo: 'ids', 44 * urlSuffixList: 'properties', 45 * paramList: 'return=id,name', 46 * listFields: ['id', 'name'], 47 * isDefault: true}, 48 * {id: 'communes', 49 * label: 'Communes', 50 * url: projectid.config.wsRecenterCommunesUrl, 51 * urlSuffixGeo: 'features', 52 * paramIdGeo: 'ids', 53 * urlSuffixList: 'properties', 54 * paramList: 'return=id,name', 55 * listFields: ['id', 'name']} 40 56 * ] 41 57 * … … 44 60 * id : id of the search service 45 61 * label : label displayed over the service combobox 46 * url : main url of the target webservice. If the webservice is on another domain, simply set it as a local url and use an Apache's proxy redirection (rewrite.conf) 47 * urlSuffixGeo : suffix appended to the url to obtain the geojson (x,y at the moment) to do the final recentering 48 * paramIdGeo : id of the parameter to obtain the geojson. The value is automaticaly recovered from the user choice in the combobox values list 49 * urlSuffixList : suffix appended to the url to obtain the list of elements which will be proposed to the user 50 * paramList : whole list of parameter=value needed to obtain the list of elements which will be proposed to the user 51 * listFields : array of id of the elements returned by the webservice, used to initialize the store object which will feed the list of elements which will be proposed to the user. May be the same as the paramList elements. 62 * url : main url of the target webservice. If the webservice is on another 63 * domain, simply set it as a local url and use an Apache's proxy redirection 64 * (rewrite.conf) 65 * urlSuffixGeo : suffix appended to the url to obtain the geojson (x,y at the 66 * moment) to do the final recentering 67 * paramIdGeo : id of the parameter to obtain the geojson. The value is 68 * automaticaly recovered from the user choice in the combobox values list 69 * urlSuffixList : suffix appended to the url to obtain the list of elements 70 * which will be proposed to the user 71 * paramList : whole list of parameter=value needed to obtain the list of elements 72 * which will be proposed to the user 73 * listFields : array of id of the elements returned by the webservice, used to 74 * initialize the store object which will feed the list of elements which will 75 * be proposed to the user. May be the same as the paramList elements. 52 76 * 53 * if more that one webservice is defined, a combobox is displayed to allow the user the switch between the services 77 * if more that one webservice is defined, a combobox is displayed to allow the 78 * user the switch between the services 54 79 * 55 80 * for the "swissnames" webservice examples above, the full url would be : … … 62 87 63 88 /** 64 * Constructor: mapfish.widgets. Ws89 * Constructor: mapfish.widgets.recenter.Ws 65 90 * 66 91 * Parameters: … … 69 94 * {<mapfish.widgets.recenter.Ws>} 70 95 */ 71 72 96 mapfish.widgets.recenter.Ws = function(config) { 73 97 Ext.apply(this, config); … … 77 101 Ext.extend(mapfish.widgets.recenter.Ws, mapfish.widgets.recenter.Base, { 78 102 103 /** 104 * Property: wsRecenterstore 105 * {Ext.data.JsonStore} - JsonStore for filling recenter combobox 106 */ 79 107 wsRecenterstore: null, 108 109 /** 110 * Property: wsRecenterServicestore 111 * {Ext.data.SimpleStore} - SimpleStore for filling service combobox 112 */ 80 113 wsRecenterServicestore: null, 81 114 115 /** 116 * Property: wsRecenterServicestore 117 * {Object} Service config object 118 */ 82 119 wsRecenterCurrentService: null, 83 120 121 /** 122 * Property: errorMsg 123 * {String} Error message in case webservice is not accessible 124 */ 84 125 errorMsg: OpenLayers.i18n('mf.recenter.ws.error'), 85 126 86 127 /** 87 128 * Method: fillComponent 88 * 89 * Called by initComponent to create the component's sub-elements. 129 * Called by initComponent to create the component's sub-elements. 90 130 */ 91 131 fillComponent: function() { … … 94 134 this.initWsRecenterServicestore(); 95 135 this.initWsRecenterstore(); 96 97 /* init combobox */98 136 99 137 /** … … 130 168 131 169 /** 132 * init main recentering combobox 170 * Property: resultTpl 171 * {Ext.XTemplate} template for combobox values 172 */ 173 var resultTpl = new Ext.XTemplate( 174 '<tpl for=".">', 175 '<div class="x-combo-list-item">', 176 '<h3><span>{name}</span></h3>', 177 '</div>', 178 '</tpl>' 179 ); 180 181 /** 182 * Property: wsRecenterCombo 183 * {Ext.form.ComboBox} template for combobox values 184 * init main recentering combobox 133 185 */ 134 186 var wsRecenterCombo = new Ext.form.ComboBox({ … … 136 188 name: 'wsRecenter', 137 189 value: '', 190 tpl: this.wsRecenterCurrentService.tpl || resultTpl, 138 191 displayField: 'name', 139 192 mode: 'remote', … … 163 216 this.add(wsRecenterCombo); 164 217 165 /* handle scales selection for recentering */218 /* handle scales selection for recentering */ 166 219 if (this.scales) { 167 220 this.addScaleCombo('Ws'); … … 171 224 172 225 /** 173 * change current webservice based on user selection 174 * @param object combo Ext.form.ComboBox 226 * Method: onWsRecenterServicesSelect 227 * change current webservice based on user selection 228 * 229 * Parameters: 230 * {Ext.form.ComboBox} combo - combobox reference 175 231 */ 176 232 onWsRecenterServicesSelect: function(combo) { … … 180 236 181 237 /** 182 * recenter on geometry after the user has selected an option in the combobox 183 * @param object combo Ext.form.ComboBox 238 * Method: onWsRecenterSelect 239 * recenter on geometry after the user has selected an option in the 240 * combobox 241 * 242 * Parameters: 243 * {Ext.form.ComboBox} combo - combobox reference 184 244 */ 185 245 onWsRecenterSelect: function(combo) { … … 189 249 // prevent action if user press enter only on first try 190 250 } 191 var url = this.wsRecenterCurrentService.url + this.wsRecenterCurrentService.urlSuffixGeo + '?' + this.wsRecenterCurrentService.paramIdGeo + '=' + combo.value; 251 var url = this.wsRecenterCurrentService.url; 252 url += this.wsRecenterCurrentService.urlSuffixGeo + '?'; 253 url += this.wsRecenterCurrentService.paramIdGeo + '=' + combo.value; 254 192 255 OpenLayers.Request.GET({ 193 256 url: url, … … 209 272 } 210 273 211 this.recenterOnCoords(feature.geometry.x, feature.geometry.y, zoom); 274 this.recenterOnCoords(feature.geometry.x, 275 feature.geometry.y, zoom); 212 276 213 277 }, 214 278 failure: function(response) { 215 var msg = this.errorMsg + "<br /><br />" + url + "<br /><br />" + response.status + "<br />" + response.statusText; 279 var msg = this.errorMsg + "<br /><br />" + url + "<br /><br />"; 280 msg += response.status + "<br />" + response.statusText; 281 216 282 this.showError(msg); 217 283 }, … … 221 287 }, 222 288 223 /** 224 * Initializes recenter service: get default recenter service from config 289 /** 290 * Method: initWsRecenterService 291 * Initializes recenter service: get default recenter service from config 225 292 */ 226 293 initWsRecenterService: function () { … … 233 300 }, 234 301 235 /** 236 * Changes recenter service 237 * @param string serviceId 302 /** 303 * Method: setWsRecenterService 304 * Changes recenter service 305 * 306 * Parameters: 307 * {String} serviceId - service id 238 308 */ 239 309 setWsRecenterService: function (serviceId) { … … 243 313 } 244 314 } 245 //this.initWsRecenterstore(); 246 this.wsRecenterstore.proxy.conn.url = this.wsRecenterCurrentService.url + this.wsRecenterCurrentService.urlSuffixList + '?' + this.wsRecenterCurrentService.paramList; 315 var url = this.wsRecenterCurrentService.url; 316 url += this.wsRecenterCurrentService.urlSuffixList + '?'; 317 url += this.wsRecenterCurrentService.paramList; 318 this.wsRecenterstore.proxy.conn.url = url 247 319 this.wsRecenterstore.load(); 248 320 }, 249 321 250 /** 251 * store for first webservice call, get options liste 322 /** 323 * Method: initWsRecenterstore 324 * store for first webservice call, get options liste 252 325 */ 253 326 initWsRecenterstore: function () { … … 260 333 loadexception: function(proxy, options, response) { 261 334 if (response.status < 200 || response.status >= 300) { 262 var msg = this.errorMsg + "<br /><br />" + this.wsRecenterstore.proxy.conn.url + "<br /><br />" + response.status + "<br />" + response.statusText; 335 var msg = this.errorMsg + "<br /><br />"; 336 msg += this.wsRecenterstore.proxy.conn.url + "<br /><br />" 337 msg += response.status + "<br />" + response.statusText; 263 338 this.showError(msg); 264 339 } … … 269 344 270 345 /** 271 * init store for services selector 346 * Method: initWsRecenterServicestore 347 * init store for services selector 272 348 */ 273 349 initWsRecenterServicestore: function () { 274 350 var myData = []; 275 351 for (var i = 0; i < this.wsRecenterServices.length; i++) { 276 myData[i] = [this.wsRecenterServices[i].id, this.wsRecenterServices[i].label]; 352 myData[i] = [this.wsRecenterServices[i].id, 353 this.wsRecenterServices[i].label]; 277 354 } 278 355 … … 284 361 285 362 /** 286 * return domain from wsRecenterUrl 287 * @return string domain d 363 * Method: wsDomain 364 * return domain from wsRecenterUrl 365 * 366 * Returns: 367 * {String} domain d 288 368 */ 289 369 wsDomain: function() {