2
I have a Pageview that, in one of its Fragments, houses a Mapview with a map in "Lite" mode. Clicking on this map, a second Activity is launched (startActivityForResult
) which consists of a complete map, where it is possible to mark a particular location. In the onActivityResult()
from Fragment, I select the camera for the position marked on the full map.
I know there is a time until the map is loaded on the specified position and zoom, so I created a spinner on the map with the attribute "Gone" in visibility. When in the onActivityResult
, change this attribute dynamically to Visible
.
Problem
At some point, I need to inform you that the spinner should get "Gone" again. The question is: where?
What I’ve already tried
I tried to implement some Googlemaps interfaces such as OnMapLoadedCallback
and OnMapReadyCallback
. OnMapReadyCallback
is still called, but not when I want, after moving the camera.
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/*Prevent null pointer when user kill the second activity without having results
Requestcode is not being checked because there is no more than one request for "startActivityForResults"
*/
if(data != null) {
map.clear();
pbStaticMap.setVisibility(View.VISIBLE);
Double latitude;
Double longitude;
latitude = (Double) data.getExtras().get("lat");
longitude = (Double) data.getExtras().get("long");
this.markPosition = new LatLng(latitude, longitude);
map.addMarker(new MarkerOptions().position(markPosition));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(markPosition, 15));
}
}
map.setOnMapLoadedCallback( new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
pbStaticMap.setVisibility(View.GONE);
Log.d("MapBorba","->>> chamou onMapLoaded ( NEW CALLBACK)");
}
});
thank you so much for your attention. I have tried to make use of this callback. But unfortunately it is called as soon as you receive the position change instruction. That is, I give Gone on the spinner before the map is actually displaying what it should...
– Rodrigo Borba