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:
@@ -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 }
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user