Skip to content

Instantly share code, notes, and snippets.

@anta40
Created June 8, 2024 17:48
Show Gist options
  • Save anta40/9ef3d93a1ac63f579a23cea47df2945a to your computer and use it in GitHub Desktop.
Save anta40/9ef3d93a1ac63f579a23cea47df2945a to your computer and use it in GitHub Desktop.
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions
class AboutFragment : Fragment(), OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val mapFragment = childFragmentManager.findFragmentById(R.id.store_map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
return inflater.inflate(R.layout.fragment_about, container, false)
}
override fun onMapReady(gmap: GoogleMap) {
val STORE_POSITION = LatLng(-6.20175, 106.78208)
val markerOptions = MarkerOptions().position(STORE_POSITION).title("Awesome Store").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_location))
gmap.addMarker(markerOptions)
gmap.moveCamera(CameraUpdateFactory.newLatLng(STORE_POSITION))
gmap.animateCamera(CameraUpdateFactory.zoomTo(20f))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment