Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With the new release of the Google Play Services, Google added a <a href="https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap#snapshot%28com.google.android.gms.maps.GoogleMap.SnapshotReadyCallback,%20android.graphics.Bitmap%29" rel="nofollow">snapshot</a> method in order to retrieve a Bitmap of the currenrt shown map, which instead may be shown. So interaction is not possible but at leased the map is not shaking anymore. </p> <p>use </p> <pre><code>GoogleMap.snapshot (GoogleMap.SnapshotReadyCallback callback) </code></pre> <p>and implement the SnapshotReadyCallback. Once the Snapshot is delivered, replace the MapFragment with an ImageView containing the Snapshot.</p> <p>This example works pretty well in the onResume method: </p> <pre><code>@Override public void onResume() { super.onResume(); notifyDataChanged(); final ViewTreeObserver viewTreeObserver = fragmentMap.getView() .getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver .addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { onMesuredMap(this); } }); } } private void onMesuredMap(OnGlobalLayoutListener listener) { if (fragmentMap.getView().getWidth() != 0 &amp;&amp; fragmentMap.getView().getHeight() != 0) { fragmentMap.getView().getViewTreeObserver() .removeOnGlobalLayoutListener(listener); makeSnapShot(); } } private void makeSnapShot() { Runnable action = new Runnable() { @Override public void run() { fragmentMap.getMap().snapshot(new SnapshotReadyCallback() { @Override public void onSnapshotReady(Bitmap arg0) { imageViewStaticMap.setImageBitmap(arg0); removeMapFragment(); } }); } }; //litle hack to make sure that the map is loaded for sure fragmentMap.getView().postDelayed(action, 1500); } private void removeMapFragment() { if (fragmentMap.isVisible()) { getChildFragmentManager() .beginTransaction() .remove(fragmentMap) .commit(); } } </code></pre> <p><strong>Sidenote:</strong> To use the new release run an Update of the Android SDK Manager, and when using maven run the <a href="https://github.com/mosabua/maven-android-sdk-deployer" rel="nofollow">maven-android-sdk-deployer</a> with:</p> <pre><code>mvn install -fae </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload