I need to add the streetview into a fragment
public class Streetview extends Fragment implements OnStreetViewPanoramaReadyCallback {
WebView wv1;
SupportMapFragment mSupportMapFragment;
private GoogleMap googleMap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.fragment_streetview, container, false);
StreetViewPanoramaFragment streetViewPanoramaFragment =
(StreetViewPanoramaFragment) getFragmentManager()
.findFragmentById(R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(this);
return view;
}
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
panorama.setPosition(new LatLng(-33.87365, 151.20689));
} }
https://developers.google.com/maps/documentation/android-api/streetview
I tried that but its not working
How to add streetview to a fragment in android?
You're in a Fragment, already, so you can use a StreetViewPanoramaView
in your XML, not another Fragment.
In the link you posted, there are examples of that class
I would suggest using that instead.
StreetViewPanoramaFragment
already is a Fragment, so you ideally should not have it inside another one. You instead should use it directly from the Activity, like your link shows.
If you did want that, though, a Fragment in another Fragment, needs to be gotten from the getChildFragmentManager()
. No guarantees that works, though.