/**
* GeometryEntity service constructor
* @class
* @constructor
* @extends {cercalia.service.Service}
*/
cercalia.service.GeometryEntity = function() {
/**
* @private
* @type {string}
*/
this.cercaliaKey_ = cercaliaGlobals.key;
/**
* @private
* @type {string}
*/
this.server_ = servers.servlet;
/**
* @private
* @type {string}
*/
this.CLASS_NAME_ = 'cercalia.service.ReverseGeocoding';
};
/**
* Gets the address from a coordinate cercalia.LonLat
* @param {string} countryId Country Id.
* @param {string} postalCode Postal code.
* @param {Function} callbackFn Callback Function to parse data server response.
*/
cercalia.service.GeometryEntity.prototype.getPostalCodeGeometry = function(countryId, postalCode, callbackFn) {
var params = {
key: this.cercaliaKey_,
cmd: 'geoment',
countryId: countryId,
postalCode: postalCode
};
cercalia.jQuery.ajax({
url: this.server_,
data: params,
type: 'GET',
method: 'GET',
dataType: cercalia.Util.isIEUnderTen() ? 'jsonp' : 'json',
crossDomain: true,
success: function(data){
if(callbackFn){
callbackFn(data);
}
},
error: cercalia.AJAXException
});
};
/**
* @param {string} municipalityId Municipality.
* @param {Function} callbackFn Callback function to parse data server response.
*/
cercalia.service.GeometryEntity.prototype.getMunicipalityGeometry = function(municipalityId, callbackFn) {
var params = {
key: this.cercaliaKey_,
cmd: 'geoment',
municipalityId: municipalityId
};
cercalia.jQuery.ajax({
url: this.server_,
data: params,
type: 'GET',
method: 'GET',
dataType: cercalia.Util.isIEUnderTen() ? 'jsonp' : 'json',
crossDomain: true,
success: function(data){
if(callbackFn){
callbackFn(data);
}
},
error: cercalia.AJAXException
});
};