Skip to content

Commit

Permalink
feat: Add Kotlin Flow extensions for maps-ktx and maps-v3-ktx (#144)
Browse files Browse the repository at this point in the history
* feat: Add camera specific flow events and deprecate cameraEvents(). (#113)

* feat: Add circleClickEvents() (#131)

* feat: Add groundOverlayClicks() (#132)

* feat: Add indoorStateChangeEvents() (#138)

* feat: Add indoorStateChangeEvents()

* Update demo to use local maps-ktx

* feat: Add flow support for info window events. (#139)

* feat: Add more flow events

Added the following APIs:
* mapClickEvents()
* mapLongClickEvents()
* markerClickEvents()
* markerDragEvents()
* myLocationButtonClickEvents()

* chore: Bump Maps version to 17.0.1 and compile/target sdk to 30

* feat: Add remaining flow extensions

Added the following APIs:

* myLocationClickEvents()
* poiClickEvents()
* polygonClickEvents()
* polylineClickEvents()

* feat: Add flow extensions to StreetViewPanoramaView.
  • Loading branch information
arriolac committed Jun 7, 2021
1 parent 01efbad commit e5cc99f
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 22 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ dependencies {
implementation deps.androidx.coreKtx
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.google.maps.android:maps-ktx:3.0.1'
// implementation 'com.google.maps.android:maps-ktx:3.0.1'
implementation 'com.google.maps.android:maps-utils-ktx:3.0.1'
// implementation project(':maps-ktx')
// implementation project(':maps-utils-ktx')
implementation project(':maps-ktx')
// implementation project(':maps-utils-ktx')
}

secrets {
Expand All @@ -64,4 +64,4 @@ secrets {
// MAPS_API_KEY=YOUR_API_KEY
propertiesFileName 'secure.properties'
defaultPropertiesFileName 'secure.defaults.properties'
}
}
21 changes: 12 additions & 9 deletions app/src/main/java/com/google/maps/android/ktx/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import com.google.maps.android.ktx.awaitMap
import com.google.maps.android.ktx.awaitMapLoad
import com.google.maps.android.ktx.awaitSnapshot
import com.google.maps.android.ktx.cameraEvents
import com.google.maps.android.ktx.awaitMap
import com.google.maps.android.ktx.cameraIdleEvents
import com.google.maps.android.ktx.cameraMoveStartedEvents
import com.google.maps.android.ktx.demo.io.MyItemReader
import com.google.maps.android.ktx.demo.model.MyItem
import com.google.maps.android.ktx.model.cameraPosition
Expand All @@ -54,6 +57,7 @@ import com.google.maps.android.ktx.utils.geojson.geoJsonLayer
import com.google.maps.android.ktx.utils.kml.kmlLayer
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import org.json.JSONException

/**
Expand Down Expand Up @@ -94,15 +98,14 @@ class MainActivity : AppCompatActivity() {
}
showMapLayers(googleMap)
addButtonClickListener(googleMap)
googleMap.cameraEvents().collect { event ->
when (event) {
is CameraIdleEvent -> Log.d(TAG, "Camera is idle.")
is CameraMoveCanceledEvent -> Log.d(TAG, "Camera move canceled")
is CameraMoveEvent -> Log.d(TAG, "Camera moved")
is CameraMoveStartedEvent -> Log.d(
TAG,
"Camera moved started. Reason: ${event.reason}"
)
launch {
googleMap.cameraMoveStartedEvents().collect {
Log.d(TAG, "Camera moved.")
}
}
launch {
googleMap.cameraIdleEvents().collect {
Log.d(TAG, "Camera is idle.")
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ buildscript {
ext.versions = [
'android' : [
"buildTools": "29.0.3",
"compileSdk": 29,
"compileSdk": 30,
"minSdk" : 15,
"targetSdk" : 29
"targetSdk" : 30
],
'androidMapsUtils' : '2.0.1',
'androidMapsUtils' : '2.2.3',
'androidx' : [
'appcompat': '1.1.0',
'coreKtx' : '1.2.0',
Expand All @@ -36,7 +36,7 @@ buildscript {
'mapsBeta' : '3.1.0-beta',
'mockito' : '3.0.0',
'mockitoKotlin' : '2.2.0',
'playServices' : '17.0.0',
'playServices' : '17.0.1',
'volley' : '1.2.0',
]

Expand Down
Loading

0 comments on commit e5cc99f

Please sign in to comment.