Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Maps3DSamples/ApiDemos/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ dependencies {
implementation(libs.androidx.material3)

api(libs.play.services.base) // "com.google.android.gms:play-services-base:18.10.0"
api(libs.play.services.maps3d) // "com.google.android.gms:play-services-maps3d:0.2.0"
api(libs.play.services.maps3d) // "com.google.android.gms:play-services-maps3d:0.2.2"
}
2 changes: 1 addition & 1 deletion Maps3DSamples/ApiDemos/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lifecycleRuntimeKtx = "2.10.0"
material = "1.13.0"

playServicesBase = "18.10.0"
playServicesMaps3d = "0.2.0"
playServicesMaps3d = "0.2.2"
secretsGradlePlugin = "2.0.1"
truth = "1.4.5"
uiautomator = "2.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ abstract class SampleBaseActivity : AppCompatActivity(), OnMap3DViewReadyCallbac
Log.d(TAG, "onMap3DViewReady called")
Log.d(TAG, "Setting initial camera: " + initialCamera.toCameraString())
// Wire up the standardized listener
googleMap3D.setOnMapReadyListener {
Log.w(TAG, "on map ready listener")
googleMap3D.setOnMapReadyListener { sceneReadiness->
Log.w(TAG, "on map ready listener $sceneReadiness")
googleMap3D.setOnMapReadyListener(null)
onMapReady(googleMap3D)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner
import com.example.advancedmaps3dsamples.ui.theme.AdvancedMaps3DSamplesTheme
import com.google.android.gms.maps3d.GoogleMap3D
import com.google.android.gms.maps3d.Map3DOptions
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.Map3DView
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback

Expand Down Expand Up @@ -51,8 +51,8 @@ class BasicComposeMapActivity : ComponentActivity() {
// Composable enters the composition. Without `remember`, a new Map3DView would
// be created on every recomposition, causing severe performance issues and losing state.
val map3DView = remember {
// Map3DOptions allows us to set the initial camera position and orientation.
val options = Map3DOptions(
// Map3DInitConfig allows us to set the initial camera position and orientation.
val options = Map3DInitConfig.create(
centerLat = 21.350,
centerLng = -157.800,
centerAlt = 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import com.example.advancedmaps3dsamples.utils.toHeading
import com.example.advancedmaps3dsamples.utils.toValidCamera
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps3d.GoogleMap3D
import com.google.android.gms.maps3d.Map3DOptions
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.Map3DView
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback
import com.google.android.gms.maps3d.model.AltitudeMode
Expand Down Expand Up @@ -335,7 +335,7 @@ private fun Map3DViewport(
) {
val context = LocalContext.current
AndroidView(modifier = Modifier.fillMaxSize().testTag("map3d_view"), factory = {
val options = Map3DOptions(
val options = Map3DInitConfig.create(
centerLat = 21.350,
centerLng = -157.800,
centerAlt = 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.example.advancedmaps3dsamples.utils.wrapIn
import com.google.android.gms.maps3d.GoogleMap3D

private val headingSliderRange = -180f..180f
private val tiltSliderRange = 0f..90f
Expand Down Expand Up @@ -71,7 +70,7 @@ fun CameraControlDemoScreen(
Column(modifier = Modifier.fillMaxSize()) {
ThreeDMap(
modifier = Modifier.fillMaxWidth().weight(1f),
options = scenario.mapsOptions,
mapsConfig = scenario.mapsConfig,
viewModel = viewModel,
)
Spacer(modifier = Modifier.height(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package com.example.advancedmaps3dsamples.scenarios

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.google.android.gms.maps3d.Map3DOptions
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.model.Camera
import com.google.android.gms.maps3d.model.MarkerOptions
import com.google.android.gms.maps3d.model.ModelOptions // Import ModelOptions
Expand All @@ -28,7 +28,7 @@ import com.google.android.gms.maps3d.model.latLngAltitude
data class Scenario(
val name: String,
val titleId: Int,
val mapsOptions: Map3DOptions,
val mapsConfig: Map3DInitConfig,
val animationSteps: List<AnimationStep> = emptyList(),
val markers: List<MarkerOptions> = emptyList(),
val models: List<ModelOptions> = emptyList(), // Add models property
Expand All @@ -38,8 +38,8 @@ data class Scenario(
@Composable fun getTitle() = stringResource(titleId)

fun reset(viewModel: ScenariosViewModel) {
viewModel.setCamera(mapsOptions.toCamera()) // Set initial camera
viewModel.setMapMode(mapsOptions.mapMode)
viewModel.setCamera(mapsConfig.toCamera()) // Set initial camera
viewModel.setMapMode(mapsConfig.mapMode)

viewModel.clearObjects()

Expand Down Expand Up @@ -74,7 +74,7 @@ fun createScenario(
return Scenario(
name = name,
titleId = titleId,
mapsOptions = initialState.toMaps3DOptions(),
mapsConfig = initialState.toMaps3DInitConfig(),
animationSteps = animationString.toAnimation(),
markers = markers.toMarkers(),
models = models.toModels(),
Expand All @@ -83,7 +83,7 @@ fun createScenario(
)
}

fun Map3DOptions.toCamera(): Camera {
fun Map3DInitConfig.toCamera(): Camera {
val options = this
return camera {
center = latLngAltitude {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.example.advancedmaps3dsamples.utils.toRoll
import com.example.advancedmaps3dsamples.utils.toTilt
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps3d.model.PolygonOptions
import com.google.android.gms.maps3d.Map3DOptions
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.model.AltitudeMode
import com.google.android.gms.maps3d.model.Camera
import com.google.android.gms.maps3d.model.CollisionBehavior
Expand Down Expand Up @@ -189,15 +189,15 @@ fun String.toAnimation(): List<AnimationStep> {
}
}

fun String.toMaps3DOptions(): Map3DOptions {
fun String.toMaps3DInitConfig(): Map3DInitConfig {
var camera: Camera? = null
var mode: Int = Map3DMode.SATELLITE

val optionsString = this.trim().trimEnd(';')
if (optionsString.isBlank()) {
Log.w(TAG, "Empty initialState string provided for Map3DOptions")
Log.w(TAG, "Empty initialState string provided for Map3DInitConfig")
// Return default options
return Map3DOptions(defaultUiDisabled = true)
return Map3DInitConfig.create()
}

optionsString.split(";").forEach { option ->
Expand Down Expand Up @@ -227,8 +227,7 @@ fun String.toMaps3DOptions(): Map3DOptions {
altitude = 10_000_000.0
}

return Map3DOptions(
defaultUiDisabled = true,
return Map3DInitConfig.create(
centerLat = camera?.center?.latitude ?: defaultCameraPos.latitude,
centerLng = camera?.center?.longitude ?: defaultCameraPos.longitude,
centerAlt = camera?.center?.altitude ?: defaultCameraPos.altitude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package com.example.advancedmaps3dsamples.scenarios

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.google.android.gms.maps3d.GoogleMap3D

@Composable
fun ScenarioScreen(
Expand All @@ -26,7 +25,7 @@ fun ScenarioScreen(
) {
ThreeDMap(
modifier = modifier,
options = scenario.mapsOptions,
mapsConfig = scenario.mapsConfig,
viewModel = viewModel,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.viewinterop.AndroidView
import com.google.android.gms.maps3d.GoogleMap3D
import com.google.android.gms.maps3d.Map3DOptions
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.Map3DView
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback

@Composable
internal fun ThreeDMap(
options: Map3DOptions,
mapsConfig: Map3DInitConfig,
viewModel: ScenariosViewModel,
modifier: Modifier = Modifier,
) {
Expand All @@ -39,7 +39,7 @@ internal fun ThreeDMap(
AndroidView(
modifier = modifier.testTag("map3d_view"),
factory = { context ->
val map3dView = Map3DView(context = context, options = options)
val map3dView = Map3DView(context = context, config = mapsConfig)
map3dView.onCreate(null)

map3dView.getMap3DViewAsync(
Expand Down
2 changes: 1 addition & 1 deletion Maps3DSamples/advanced/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ composeBom = "2026.01.01"

hilt = "2.57.2"
ksp = "2.2.20-2.0.2"
playServicesMaps3d = "0.2.0"
playServicesMaps3d = "0.2.2"
playServicesBase = "18.10.0"
secretsGradlePlugin = "2.0.1"
truth = "1.4.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationServices
import com.google.android.gms.maps3d.GoogleMap3D
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.model.Camera
import com.google.android.gms.maps3d.model.Map3DMode
import com.google.android.gms.maps3d.model.camera
Expand Down Expand Up @@ -196,7 +197,7 @@ class MainActivity : AppCompatActivity(), OnMap3DViewReadyCallback {
val lifecycleOwner = androidx.lifecycle.compose.LocalLifecycleOwner.current

val map3DView = remember {
com.google.android.gms.maps3d.Map3DView(context).apply {
com.google.android.gms.maps3d.Map3DView(context, Map3DInitConfig.create()).apply {
getMap3DViewAsync(this@MainActivity)
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lifecycleRuntimeKtx = "2.10.0"
material = "1.13.0"

playServicesBase = "18.10.0"
playServicesMaps3d = "0.2.0"
playServicesMaps3d = "0.2.2"
places = "5.2.0"
secretsGradlePlugin = "2.0.1"
truth = "1.4.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.google.android.gms.maps3d.GoogleMap3D
import com.google.android.gms.maps3d.Map3DOptions
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.Map3DView
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback
import com.google.android.gms.maps3d.model.Camera
import com.google.android.gms.maps3d.model.CameraRestriction
import com.google.android.gms.maps3d.model.LatLngAltitude
import com.google.android.gms.maps3d.model.Map3DMode
import com.google.maps.android.compose3d.utils.toValidCamera
import com.google.maps.android.compose3d.utils.toValidCameraRestriction
import com.google.android.gms.maps3d.model.LatLngAltitude

/**
* A declarative Compose wrapper for the Google Maps 3D SDK [Map3DView].
Expand Down Expand Up @@ -69,7 +69,7 @@ fun GoogleMap3D(
popovers: List<PopoverConfig> = emptyList(),
cameraRestriction: CameraRestriction? = null,
@Map3DMode mapMode: Int = Map3DMode.SATELLITE,
options: Map3DOptions = Map3DOptions(),
options: Map3DInitConfig = Map3DInitConfig.create(),
onMapReady: (GoogleMap3D) -> Unit = {},
onMapSteady: () -> Unit = {},
onMapClick: ((LatLngAltitude) -> Unit)? = null,
Expand Down
2 changes: 1 addition & 1 deletion snippets/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lifecycleRuntimeKtx = "2.10.0"
material = "1.13.0"

playServicesBase = "18.10.0"
playServicesMaps3d = "0.2.0"
playServicesMaps3d = "0.2.2"
secretsGradlePlugin = "2.0.1"
truth = "1.4.5"
uiautomator = "2.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.example.snippets.java.annotations.SnippetGroup;
import com.example.snippets.java.annotations.SnippetItem;
import com.google.android.gms.maps3d.GoogleMap3D;
import com.google.android.gms.maps3d.Map3DInitConfig;
import com.google.android.gms.maps3d.Map3DView;
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback;
import com.google.android.gms.maps3d.OnMapReadyListener;
Expand All @@ -43,7 +44,7 @@ public class MapInitSnippets {
@SuppressWarnings("unused")
public void basicMap3D(Context context) {
// [START maps_android_3d_init_basic_java]
Map3DView map3DView = new Map3DView(context);
Map3DView map3DView = new Map3DView(context, Map3DInitConfig.create());

// Get the map asynchronously
map3DView.getMap3DViewAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.ui.viewinterop.AndroidView
import com.example.snippets.kotlin.annotations.SnippetGroup
import com.example.snippets.kotlin.annotations.SnippetItem
import com.google.android.gms.maps3d.GoogleMap3D
import com.google.android.gms.maps3d.Map3DInitConfig
import com.google.android.gms.maps3d.Map3DView
import com.google.android.gms.maps3d.OnMap3DViewReadyCallback
import com.google.android.gms.maps3d.model.camera
Expand Down Expand Up @@ -55,7 +56,7 @@ class MapInitSnippets {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
Map3DView(context).apply {
Map3DView(context, Map3DInitConfig.create()).apply {
getMap3DViewAsync(object : OnMap3DViewReadyCallback {
override fun onMap3DViewReady(googleMap3D: GoogleMap3D) {
val camera = camera {
Expand Down
Loading