UNPKG

@sinch/mcp

Version:

Sinch MCP server

43 lines 1.48 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLatitudeLongitudeFromAddress = void 0; const axios_1 = __importDefault(require("axios")); const getLatitudeLongitudeFromAddress = async (address) => { const fallbackCoordinates = { latitude: 0, longitude: 0, formattedAddress: 'Unknown' }; try { const url = 'https://maps.googleapis.com/maps/api/geocode/json'; const queryParams = { address, key: process.env.GEOCODING_API_KEY }; const response = await axios_1.default.get(url, { params: queryParams }); const data = response.data; if (data.status === 'OK') { const location = data.results[0].geometry.location; return { latitude: location.lat, longitude: location.lng, formattedAddress: data.results[0].formatted_address }; } else { console.error('Geocoding failed:', data.status); return fallbackCoordinates; } } catch (error) { console.error('Request failed:', error); return fallbackCoordinates; } }; exports.getLatitudeLongitudeFromAddress = getLatitudeLongitudeFromAddress; //# sourceMappingURL=geocoding.js.map