googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.12k stars 131 forks source link

Remove public currentCameraPositionState property #500

Open bubenheimer opened 7 months ago

bubenheimer commented 7 months ago

Compose 4.3.0

262 introduced a public currentCameraPositionState property. I don't think this was a good idea from an architectural standpoint, as this allows & suggests configuring the map from inside the map subcomposition by user code. Map configuration is generally intended to be done at the top level via parameters of the GoogleMap() composable. CameraPositionState is one of the parameters passed to GoogleMap(), duplicating responsibilities for CameraPositionState configuration.

If user code does need access to CameraPositionState from inside the subcomposition it can pass it down itself in whatever form it deems most appropriate: read-only position, read/write state, or some other kind of wrapper; captured lambda variable, parameter, or CompositionLocal. These decisions need to be left to user code.

bubenheimer commented 7 months ago

This concern could be addressed by making the property non-public or whatever "internal" library consumers actually need.

bubenheimer commented 7 months ago

Also, this property, in its present form, prevents performing initial composition of the GoogleMap() subcomposition in parallel with GoogleMap object initialization: #501

Edit: I don't think this is the case, actually.