/**
* ReverseGeocoding service constructor
* @class
* @constructor
*/
cercalia.service.ReverseGeocoding = function() {
/**
* @private
* @type {string}
*/
this.cercaliaKey_ = cercaliaGlobals.key; //Esta variable siempre se pasara al descargar la API
/**
* @private
* @type {string}
*/
this.server_ = servers.servlet;
/**
* @private
* @type {boolean}
*/
this.async_ = true;
/**
* Class name
* @private
* @type {string}
*/
this.CLASS_NAME_ = 'cercalia.service.ReverseGeocoding';
};
/**
* Change geocoding request synchronously.
* @param {boolean} async
*/
cercalia.service.ReverseGeocoding.prototype.setAsync = function(async) {
this.async_ = async;
};
/**
* Gets the address from a coordinate cercalia.LonLat
* @param {cercalia.LonLat} lonLat
* @param {Function} callbackFn
*/
cercalia.service.ReverseGeocoding.prototype.getDirection = function(lonLat, callbackFn) {
var mo = lonLat.getLat() + ',' + lonLat.getLon();
var params = {
key: this.cercaliaKey_,
cmd: 'reversegeocoding',
mo: mo
};
cercalia.jQuery.ajax({
type: 'GET',
method: 'GET',
dataType: cercalia.Util.isIEUnderTen() ? 'jsonp' : 'json',
url: this.server_,
async: this.async_ ? this.async_ : true,
crossDomain: true,
data: params,
success: function(data) {
if (callbackFn) {
callbackFn(data);
}
},
error: cercalia.AJAXException
});
};
/**
* Returns the object type.
* @return {string}
*/
cercalia.service.ReverseGeocoding.prototype.getClass = function() {
return this.CLASS_NAME_;
};