fix(946) Center from town name instead of calculate center

This commit is contained in:
Pontus Dreij
2024-11-21 14:15:51 +01:00
parent 01638f4dd7
commit 08e71a8dc6
12 changed files with 64 additions and 44 deletions
+17
View File
@@ -30,6 +30,7 @@ import {
import { getVerifiedUser, parsedUser } from "../user/query"
import {
getBreakfastPackageInputSchema,
getCityCoordinatesInputSchema,
getHotelDataInputSchema,
getHotelsAvailabilityInputSchema,
getRatesInputSchema,
@@ -1078,4 +1079,20 @@ export const hotelQueryRouter = router({
)
}),
}),
map: router({
get: serviceProcedure
.input(getCityCoordinatesInputSchema)
.query(async function ({ input }) {
const apiKey = process.env.GOOGLE_STATIC_MAP_KEY
const { city } = input
const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(city)}&key=${apiKey}`
const response = await fetch(url)
const data = await response.json()
console.log("DATA_RESPONSE", data)
const { lat, lng } = data.results[0].geometry.location
return { lat, lng }
}),
}),
})