Sorry, you need to enable JavaScript to visit this website.

Map snapshot image

Map snapshot image

The snapshot functionality generates a map image with markers, routes, and shapes that are rendered on the map which you can use as:

  • a screen in another app

  • a notification

  • a social media or communicator message

Sample use case: You would like to take a screenshot of the map with markers, routes, and shapes that are rendered on the map, so you can share this picture in an email, social media, or communicator.

Sample use case: You would like to store the snapshot of the picked place in the storage, so you can display the data with the corresponding snapshot.

Use the following code snippets to take a snapshot of a map:

  • MapFragment

val mapFragment = activity.supportFragmentManager.findFragmentById( as MapFragment
  • MapView

val mapView: MapView = requireActivity().findViewById(

Where the snapshotCallback is defined as:

private val snapshotCallback = object : SnapshotCallback {
    override fun onSuccess(snapshot: Bitmap) {
        // The saveSnapshotToCache(snapshot) creates a file in the context.cacheDir, writes bitmap data
        // into it using snapshot.compress(CompressFormat.JPEG, 100, outputStream) then returns the file.
        // Before you can obtain URI of this file you need to define a FileProvider in the manifest.
        val snapshotFile = saveSnapshotToCache(snapshot)
        snapshotFile?.let {
            val snapshotUri = FileProvider.getUriForFile(requireContext(), FILE_PROVIDER_AUTHORITY, it)

            val shareIntent = Intent(Intent.ACTION_SEND)
            shareIntent.type = "image/jpeg"
            shareIntent.putExtra(Intent.EXTRA_STREAM, snapshotUri)
            startActivity(Intent.createChooser(shareIntent, "Send map snapshot"))
        } ?: run { Toast.makeText(requireContext(), FILE_NOT_FOUND, Toast.LENGTH_SHORT).show() }

    override fun onError(error: Throwable) {
        Toast.makeText(requireContext(), error.message, Toast.LENGTH_SHORT).show()