All my tabs work properly and looks like the map is trying to work (I see the Google logo in the bottom left, but map is not rendering.
Here are my Fragment activity:
public class BarberMapActivity extends Fragment implements
OnMapReadyCallback{
private GoogleMap mMap;
public static BarberMapActivity newInstance() {
BarberMapActivity fragment = new BarberMapActivity();
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.barber_map_tab, null, false);
SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
return view;
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(34.0052982, -83.9888499);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
Here is my map layout:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".shopResult.tabs.BarberMapActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
您应该将SHA-1添加到您的Google Developer Console中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.