Skip to content

Commit

Permalink
feat: add samples for release 3.2.0 (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangela committed Nov 7, 2023
1 parent 0d1b558 commit 1e0053a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
Empty file added .github/snippet-bot.yml
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ build/
.gradle
*.iml
local.properties
secrets.properties
.DS_Store
.java-version
19 changes: 11 additions & 8 deletions demo-kotlin/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ plugins {
}

android {
compileSdkVersion 33
compileSdk 33
defaultConfig {
applicationId "com.example.placesdemo"
minSdkVersion 21
targetSdkVersion 33
minSdk 21
targetSdk 33
multiDexEnabled true
versionCode 1
versionName "1.0"
Expand All @@ -36,22 +36,25 @@ dependencies {
implementation "com.github.bumptech.glide:glide:4.13.2"
implementation "com.android.databinding:viewbinding:8.0.0"

// Places SDK for Android
implementation 'com.google.android.libraries.places:places:3.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.4.0'
// KTX for the Places SDK for Android library
implementation 'com.google.maps.android:places-ktx:3.0.0'

// KTX for the Maps SDK for Android Utility Library
implementation 'com.google.maps.android:maps-utils-ktx:5.0.0'
}
repositories {
mavenCentral()
}

secrets {
// To add your Google Maps Platform API key to this project:
// 1. Create or open file local.properties in this folder, which will be ready by default
// by secrets_gradle_plugin
// 1. Create or open file secrets.properties in the root folder of the project, which will be
// read by secrets_gradle_plugin
// 2. Add this line, replacing YOUR_API_KEY with a key from a project with Places API enabled:
// PLACES_API_KEY=YOUR_API_KEY
// 3. Add this line, replacing YOUR_API_KEY with a key from a project with Maps SDK for Android
// enabled (can be the same project and key as in Step 2):
// MAPS_API_KEY=YOUR_API_KEY
propertiesFileName = "secrets.properties"
defaultPropertiesFileName 'local.defaults.properties'
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import com.google.android.gms.maps.model.MapStyleOptions
import com.google.android.gms.maps.model.Marker
import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.libraries.places.api.model.Place
import com.google.android.libraries.places.api.model.TypeFilter
import com.google.android.libraries.places.api.model.PlaceTypes
import com.google.android.libraries.places.widget.Autocomplete
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode
import com.google.maps.android.SphericalUtil.computeDistanceBetween
Expand Down Expand Up @@ -101,8 +101,7 @@ class AutocompleteAddressActivity : AppCompatActivity(R.layout.autocomplete_addr
// Build the autocomplete intent with field, country, and type filters applied
val intent = Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields)
.setCountries(listOf("US"))
//TODO: https://developers.google.com/maps/documentation/places/android-sdk/autocomplete
.setTypesFilter(listOf(TypeFilter.ADDRESS.toString().lowercase()))
.setTypesFilter(listOf(PlaceTypes.ADDRESS))
.build(this)
startAutocomplete.launch(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CurrentPlaceActivity : AppCompatActivity() {
Place.Field.CURRENT_OPENING_HOURS,
Place.Field.DELIVERY,
Place.Field.DINE_IN,
Place.Field.EDITORIAL_SUMMARY,
Place.Field.OPENING_HOURS,
Place.Field.PHONE_NUMBER,
Place.Field.RESERVABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ object StringUtil {

fun convertToLatLngBounds(
southWest: String?, northEast: String?): LatLngBounds? {
val soundWestLatLng = convertToLatLng(southWest)
val southWestLatLng = convertToLatLng(southWest)
val northEastLatLng = convertToLatLng(northEast)
return if (soundWestLatLng == null || northEast == null) {
return if (southWestLatLng == null || northEastLatLng == null) {
null
} else LatLngBounds(soundWestLatLng, northEastLatLng)
} else LatLngBounds(southWestLatLng, northEastLatLng)
}

fun convertToLatLng(value: String?): LatLng? {
Expand Down
2 changes: 1 addition & 1 deletion snippets/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// [END_EXCLUDE]
// [START maps_android_places_upgrade_snippet]
implementation 'com.google.android.libraries.places:places:3.1.0'
implementation 'com.google.android.libraries.places:places:3.2.0'
// [END maps_android_places_upgrade_snippet]
}
// [END maps_android_places_install_snippet]

0 comments on commit 1e0053a

Please sign in to comment.