UNPKG

universal-geocoder

Version:

Universal geocoding abstraction server-side and client-side with multiple built-in providers

57 lines 2.26 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var provider_1 = require("../provider"); var ReverseQuery = /** @class */ (function () { function ReverseQuery(_a) { var coordinates = _a.coordinates, locale = _a.locale, _b = _a.limit, limit = _b === void 0 ? provider_1.DEFAULT_RESULT_LIMIT : _b; this.limit = provider_1.DEFAULT_RESULT_LIMIT; if (coordinates && (!coordinates.latitude || !coordinates.longitude)) { throw new Error('The "coordinates" parameter must be an object with the keys: "latitude", "longitude".'); } this.coordinates = coordinates; this.locale = locale; this.limit = limit; } ReverseQuery.create = function (object) { return new this(object); }; ReverseQuery.prototype.toObject = function () { return { coordinates: this.coordinates, locale: this.locale, limit: this.limit, }; }; ReverseQuery.prototype.withCoordinates = function (coordinates) { return this.constructor.create(__assign(__assign({}, this.toObject()), { coordinates: coordinates })); }; ReverseQuery.prototype.withLocale = function (locale) { return this.constructor.create(__assign(__assign({}, this.toObject()), { locale: locale })); }; ReverseQuery.prototype.withLimit = function (limit) { return this.constructor.create(__assign(__assign({}, this.toObject()), { limit: limit })); }; ReverseQuery.prototype.getCoordinates = function () { return this.coordinates; }; ReverseQuery.prototype.getLocale = function () { return this.locale; }; ReverseQuery.prototype.getLimit = function () { return this.limit; }; return ReverseQuery; }()); exports.default = ReverseQuery; //# sourceMappingURL=ReverseQuery.js.map