-
Notifications
You must be signed in to change notification settings - Fork 284
feat: buscar coordenadas do abrigo #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lul-cas
wants to merge
5
commits into
SOS-RS:develop
Choose a base branch
from
lul-cas:feature/get-shelter-coordinates
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+98
−3
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13d2cea
Finish Get shelter coordinates from Maps Api MVP
lul-cas 353d616
Finish interaction with Google Maps API
lul-cas 379a398
Fix: move fetch shelter coords to shelter service
lul-cas aab3cc2
Merge branch 'SOS-RS:develop' into feature/get-shelter-coordinates
lul-cas 05404e4
refactor: Move update coordinates logic to private method
lul-cas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export class MapsApi { | ||
static key: string = process.env.MAPS_API_KEY || ''; | ||
static url: string = process.env.MAPS_API_URL || 'https://maps.googleapis.com/maps/api'; | ||
|
||
static async getCoordinates(address: string): Promise<{ lat: number | null ; lng: number | null }> { | ||
try { | ||
const response = await fetch(`${MapsApi.url}/geocode/json?address=${encodeURI(address)}&key=${MapsApi.key}`); | ||
if (!response.ok) { | ||
throw new Error(`[MAPS API] Failed to fetch coordinates. Status: ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
const location = data?.results?.[0]?.geometry?.location; | ||
if (!location || !location.lat || !location.lng) { | ||
throw new Error('Invalid response from maps API'); | ||
} | ||
|
||
return location; | ||
} catch (error: any) { | ||
console.error(`[MAPS API] Error fetching coordinates: ${error.message}`); | ||
return { lat: null, lng: null }; | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Já que esta mutando o body adicionando lat/lng, não seria melhor fazer isso direto no service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realmente :D
Vou alterar, obrigado.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A propósito, acabei de ver que este PR esta utilizado o Google Maps para mostrar o local do abrigo com base no endereço
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sim, correto.
Mas se considerarmos o uso das informações como longitude e latitude do abrigo teríamos que usar a api ou semelhante. - Claro, se a implementação de futuras funcionalidades como "Achar abrigo mais próximo" ou calcular "distância" da localização atual do usuário até o abrigo x, y ainda forem relevantes.
Acha interessante prosseguir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Na minha opnião "achar abrigo mais próximo" por exemplo é bem interessante sim, apesar de talvez não ser um item de alta prioridade no momento? Estou tendo problemas pra acessar meu Discord 😓, talvez seja interessante anunciar por lá pra ver o que outras pessoas acham.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ótimo. Eu gostaria de fazer parte da comunidade, mas não encontrei link para o discord.
Eu poderia ter acesso?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wOL-Lucas eu peguei aqui nessa issue