0

I am working on app which needs geotagging and i want that whenever i press a button a new fragment opens which loads the google map with the current location and a screenshot is taken when the current location is loaded.

I have got success in taking screenshot and opening map in another fragment but i just want a way to know when our current location is loaded by google map and when it has loaded take the screenshot of it store it in sd card.

I have used How to programmatically take a screenshot in Android? for screenshot capture

Community
  • 1
  • 1
Harsh Sharma
  • 898
  • 1
  • 14
  • 30

2 Answers2

3

I think you're looking for this callback

com.google.android.gms.maps.GoogleMap.OnMapLoadedCallback

this is fired when

Callback interface for when the map has finished rendering. This occurs after all tiles required to render the map have been fetched, and all labeling is complete. This event will not fire if the map never loads due to connectivity issues, or if the map is continuously changing and never completes loading due to the user constantly interacting with the map.

Emphasis mine.

You can implement the callback and inside you call the code that takes the screenhsot.


If you need to do something after the map is loaded, and you want to know when that happens, you can implement a custom callback interface that you can manually fire when you are done with whatever it is you need to do before taking the screenshot.

Tim
  • 41,901
  • 18
  • 127
  • 145
2

You have to use the OnMapLoadedCallback listener. OnMapLoadedCallback doesn't fire until after the tiles on map are loaded. When you have a reference to the map set the call back.

mMyMap.setOnMapLoadedCallback(this);

When the onMapLoaded event fires take the snapshot.

@Override
public void onMapLoaded() {
if (mMyMap!= null) {
    mMyMap.getScreenShot(this);
}
}
Tim
  • 41,901
  • 18
  • 127
  • 145
Maheshwar Ligade
  • 6,709
  • 4
  • 42
  • 59
  • will this call back can be used for partcular task like in my case i want to load current location or it is a universal one – Harsh Sharma Sep 17 '15 at 10:38
  • If you loading map first time and get the current location then it is useful. If you want to take screen shot based on the update the current location then it will not helpful. – Maheshwar Ligade Sep 17 '15 at 10:42