-
Notifications
You must be signed in to change notification settings - Fork 0
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
GoogleMapのAPIを一旦叩けるようにした #8
Conversation
54c8b2a
to
9f63307
Compare
export default function Index() { | ||
const position = { lat: 35.689501375244, lng: 139.69173371705 }; | ||
|
||
return ( |
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.
component: Index, | ||
}); | ||
|
||
const API_KEY = import.meta.env.FRONTEND_GOOGLE_API_KEY; |
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.
これはviteの環境変数のimport方法なんだけど、環境変数まわりの管理方法はもうちょい考えたいかも
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.
確かにな。今のままでは流石にダサいから、要検討でw
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.
@takatea
サンプルありがとう〜!
localでもGoogleのAPI叩いてMapが見れるところまで確認できた!
レビューめっちゃ遅くなってすまそ
directionsService | ||
.route({ | ||
origin: "東京都新宿区西新宿2丁目8-1", // 都庁 | ||
waypoints: [{ location: "東京都港区赤坂9-7-1", stopover: true }], // ミッドタウン |
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.
最大25waypointsまでらしいわ。余裕で行けそう。
仮に25を超えるとしても、別々で計算して後でがっちゃんこするみたいなこともできるらしいし、とりま心配なさそうやな。
https://arc.net/l/quote/ucbmiyla
component: Index, | ||
}); | ||
|
||
const API_KEY = import.meta.env.FRONTEND_GOOGLE_API_KEY; |
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.
確かにな。今のままでは流石にダサいから、要検討でw
さまりー
一旦Map APIは叩けるようにしておいた
ただ、Route APIどうやって使うかは別途確認しなきゃいけない...!
→ シュッと使えないかも
やったこと
できたやつ
Mapはこんな感じ
Directions API
こんな感じ
![image](https://private-user-images.githubusercontent.com/39912547/393888572-3edda56c-5b50-46e0-8b9e-c45187b049e4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjI1NDUsIm5iZiI6MTczODk2MjI0NSwicGF0aCI6Ii8zOTkxMjU0Ny8zOTM4ODg1NzItM2VkZGE1NmMtNWI1MC00NmUwLThiOWUtYzQ1MTg3YjA0OWU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIxMDQwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ2ODdiOTNjYzE3OTNiYzQ0OWNkODdiMTQwN2U5YjUyM2U5ZjdlNjBlZGY5MDA0MWY1NzgwZmM2NjRjM2NlODEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xi9uZaOtS0TrK64Hsn_FpI597Cs715MmbPwdur7Fb9U)
ref: https://visgl.github.io/react-google-maps/examples/directions
Route API使いたい。が参考になるコードがシュッと見つからなかったのでちゃんとコード書かないといけないかも
以下でAPIキーしぼってます
ちょっと調べた
https://www.zenrin-datacom.net/solution/blog/gmpupdate-002
らしいので、Route APIを頑張って作るのが良きね。
-> もうちょい調べた
https://stackoverflow.com/questions/78081216/using-new-google-routes-api-how-can-i-render-show-route-result-to-a-map
にあるように、Routes APIはフロントでrenderするための機能は提供していないっぽい。
なので、Directions APIとDistance Matrix APIを使うのが無難かも。
もしRoutes API使うならバックエンドからAPI叩いて(フロントでもまぁいいけど)、データをバックエンドから取得して、フロントで表示とかになるんとちゃうかな。