1 (function (callback) { 2 if (typeof define === 'function' && define.amd) { 3 define(['core/AbstractWidget'], callback); 4 } 5 else { 6 callback(); 7 } 8 }(function () { 9 10 /** 11 * Offers an interface to the local parameters used by the Spatial Solr plugin. 12 * 13 * @see http://www.jteam.nl/news/spatialsolr 14 * 15 * @class AbstractSpatialWidget 16 * @augments AjaxSolr.AbstractWidget 17 */ 18 AjaxSolr.AbstractSpatialWidget = AjaxSolr.AbstractWidget.extend( 19 /** @lends AjaxSolr.AbstractSpatialWidget.prototype */ 20 { 21 /** 22 * Sets the Spatial Solr local parameters. 23 * 24 * @param {Object} params The local parameters to set. 25 * @param {Number} params.lat Latitude of the center of the search area. 26 * @param {Number} params.lng Longitude of the center of the search area. 27 * @param {Number} params.radius Radius of the search area. 28 * @param {String} [params.unit] Unit the distances should be calculated in: 29 * "km" or "miles". 30 * @param {String} [params.calc] <tt>GeoDistanceCalculator</tt> that will be 31 * used to calculate the distances. "arc" for 32 * <tt>ArchGeoDistanceCalculator</tt> and "plane" for 33 * <tt>PlaneGeoDistanceCalculator</tt>. 34 * @param {Number} [params.threadCount] Number of threads that will be used 35 * by the <tt>ThreadedDistanceFilter</tt>. 36 */ 37 set: function (params) { 38 this.manager.store.get('q').local('type', 'spatial'); 39 this.manager.store.get('q').local('lat', params.lat); 40 this.manager.store.get('q').local('long', params.lng); 41 this.manager.store.get('q').local('radius', params.radius); 42 if (params.unit !== undefined) { 43 this.manager.store.get('q').local('unit', params.unit); 44 } 45 if (params.calc !== undefined) { 46 this.manager.store.get('q').local('calc', params.calc); 47 } 48 if (params.threadCount !== undefined) { 49 this.manager.store.get('q').local('threadCount', params.threadCount); 50 } 51 }, 52 53 /** 54 * Removes the Spatial Solr local parameters. 55 */ 56 clear: function () { 57 this.manager.store.get('q').remove('type'); 58 this.manager.store.get('q').remove('lat'); 59 this.manager.store.get('q').remove('long'); 60 this.manager.store.get('q').remove('radius'); 61 this.manager.store.get('q').remove('unit'); 62 this.manager.store.get('q').remove('calc'); 63 this.manager.store.get('q').remove('threadCount'); 64 } 65 }); 66 67 })); 68