Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Using Google Maps Platform with idiomatic Kotlinまとめ 2021/07/21 Kotlin愛好会 vol.30 jollyjoester
Slide 2
Slide 2 text
この談義について ● この談義はGoogle I/O 2021のUsing Google Maps Platform with idiomatic Kotlinのセッション動画を見てまとめたものです。 ● わかりやすい構成・英語なのでぜひ見てみてください!(初中級向け?)
Slide 3
Slide 3 text
Javaで開発されているGoogle Maps PlatformのSDKを KTXを使って Kotlinらしい書き方で使えるよ! サマリ
Slide 4
Slide 4 text
背景:3つのSDK Maps SDK for Android (2012) Maps SDK Utility Library Places SDK (2015, 2019) →Javaで作られている c.f. 1:00 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en
Slide 5
Slide 5 text
背景:SDKをKotlinらしく使うには? SDK written in Java Java Kotlin Kotlin KTX SDK written in Java SDK written in Java
Slide 6
Slide 6 text
KotlinのExtention(拡張機能)の集まり JetpackとかのAPIを最適化するためによく使われる Kotlinの言語機能を使ってAndroidアプリの開発をより簡潔で快適にするよ! Maps, PlacesのKTXオープンソースになってるよ! ● android-maps-ktx ● android-places-ktx KTX
Slide 7
Slide 7 text
使い方 c.f. 4:39 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en
Slide 8
Slide 8 text
Mountain View → Mexico City へ アニメーションしながら移動する Example 1
Slide 9
Slide 9 text
Without Maps KTX c.f. 5:25 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en
Slide 10
Slide 10 text
Without KTX ①Mountain Viewまでカメラをアニメーション する
Slide 11
Slide 11 text
Without Maps KTX ②2秒待つ
Slide 12
Slide 12 text
Without Maps KTX ③Mexico Cityまでカメラをアニメーションする
Slide 13
Slide 13 text
コールバック地獄😢 見る場所が飛んでて読みにくい😢 Without KTX
Slide 14
Slide 14 text
With Maps KTX c.f. 6:29 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en ③Mexico Cityまでカメラを アニメーションする ②2秒待つ ①Mountain Viewまでカメラをア ニメーションする
Slide 15
Slide 15 text
With Maps KTX c.f. 6:29 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en サスペンド関数
Slide 16
Slide 16 text
With Maps KTX c.f. 6:29 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en サスペンド関数
Slide 17
Slide 17 text
With Maps KTX c.f. 6:29 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en サスペンド関数をどんなスコープ で実行したりするか
Slide 18
Slide 18 text
通常の同期的なコードと同じ逐次的な書き方👍 フラットで読みやすい👍 Kotlin coroutines & suspending functions🙌 With Maps KTX
Slide 19
Slide 19 text
Autocomplete Place Predictions 一部のテキスト入力すると場所を推測して取ってくるやつ Example 2
Slide 20
Slide 20 text
Without Place KTX c.f. 8:39 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en requestをビルド
Slide 21
Slide 21 text
Without Place KTX c.f. 8:39 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en SuccessとFailureのlambdaを書 く必要あり
Slide 22
Slide 22 text
With Place KTX c.f. 9:08 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en Kotlin DSL スタイル
Slide 23
Slide 23 text
With Place KTX c.f. 9:08 https://events.google.com/io/session/a898055b-44d0-460a-bf4f-b4512c964441?lng=en サスペンド関数
Slide 24
Slide 24 text
With Place KTX Kotlin DSL〜(素敵そうだけどそこまで便利さわかってない。わかる方いたら教えて🙏) ハンドラー全部実装する必要ない(すっきり〜) Kotlin coroutines & suspending functions🙌
Slide 25
Slide 25 text
● Codelabs ○ 地図をAndroidアプリに追加する ● Kotlin documentation snippets ○ Google Maps Platform Documentation ● Sample code ○ https://github.com/googlemaps/android-samples ○ https://github.com/googlemaps/android-places-demos Learning Maps & Kotlin
Slide 26
Slide 26 text
感想 Kotlin Corotinesかわいい 既存の資産を最新の形で使いやすくするKTXすごい 拡張なのででかいリファクタをしなくても部分的に新しい書き方を導入できるの便利
Slide 27
Slide 27 text
Refs. セッション動画 ● Using Google Maps Platform with idiomatic Kotlin