Merged in fix/SW-946-map-center (pull request #954)

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

Approved-by: Niclas Edenvin
This commit is contained in:
Pontus Dreij
2024-11-22 07:19:13 +00:00
12 changed files with 63 additions and 44 deletions

View File

@@ -30,6 +30,7 @@ import {
import { getVerifiedUser, parsedUser } from "../user/query"
import {
getBreakfastPackageInputSchema,
getCityCoordinatesInputSchema,
getHotelDataInputSchema,
getHotelsAvailabilityInputSchema,
getRatesInputSchema,
@@ -1081,4 +1082,19 @@ export const hotelQueryRouter = router({
)
}),
}),
map: router({
city: 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()
const { lat, lng } = data.results[0].geometry.location
return { lat, lng }
}),
}),
})