I’m working on an Android app, which displays a Google Map in a fragment. The project code is stripped down to the bare minimum. I have a Fragment declared in activity_main.xml, see code snippet:
The MainActivity.kt has commented out lines for the fragment initialization and also the onMapReady callback. However the google map is displayed, on app launch (on Emulator and actual device)
This happens even if I invalidate the Map API Key in the AndroidManifest file
I don’t understand this behavior!!
<androidx.fragment.app.FragmentContainerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment" />
```''''
``` -------------- MainActivity.kt ---------
private fun actionButton(){
// Open fragment
//val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
//mapFragment.getMapAsync(this)
val i = 1
}
override fun onMapReady(googleMap: GoogleMap) {
//mMap = googleMap
// Add a marker in Stoughton and move the camera
//val place = LatLng(42.9169, -89.2179)
//mMap.addMarker(MarkerOptions().position(place).title("Marker in Stoughton"))
//mMap.moveCamera(CameraUpdateFactory.newLatLng(place))
I tried commenting out the Fragment initialization and the OnMapCallback(), but the map is displayed upon launch
TechGuy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.