View Google Street + tilt your device

I am trying to add activity as a function to the application that I create there, the API will return a long long, and with that lat long I will load google street view. Which with the movement of the device will rotate the angle of rotation by 360 degrees. I fight for part of the movement of the device. Using your fingers on the screen, you can rotate. I wonder if someone can point me in the right direction so that the movement of the device affects the position of the street?

The code I have so far is:

import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback;
import com.google.android.gms.maps.StreetViewPanorama;
import com.google.android.gms.maps.StreetViewPanoramaFragment;
import com.google.android.gms.maps.StreetViewPanoramaOptions;
import com.google.android.gms.maps.StreetViewPanoramaView;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.StreetViewPanoramaCamera;
import com.google.android.gms.maps.model.StreetViewPanoramaLocation;

public class MainActivity extends FragmentActivity
        implements OnStreetViewPanoramaReadyCallback {

    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        StreetViewPanoramaFragment streetViewPanoramaFragment =
                (StreetViewPanoramaFragment) getFragmentManager()
                        .findFragmentById(R.id.streetviewpanorama);
        streetViewPanoramaFragment.getStreetViewPanoramaAsync(this);

    }

    @Override
    public void onStreetViewPanoramaReady(final StreetViewPanorama panorama)  {
        final long duration = 1000;
        float tilt = 30;
        float bearing = 90;
        final StreetViewPanoramaCamera camera = new StreetViewPanoramaCamera.Builder()
                .zoom(panorama.getPanoramaCamera().zoom)
                .bearing(bearing)
                .tilt(tilt)
                .build();

        panorama.setPosition(new LatLng(52.208818, 0.090587));
        panorama.setStreetNamesEnabled(false);
        panorama.setZoomGesturesEnabled(false);

        panorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
            @Override
            public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
                if (streetViewPanoramaLocation != null) {
                    panorama.animateTo(camera, duration);
                }
                Log.d(TAG, "TESTINGGGGGGGGGG");
            }
        });
    }
}
+6
source share
1 answer

I'm not sure I asked your question, so a comment if I'm wrong, but it looks like you can rotate this instruction

panorama.animateTo(camera, duration);

, "", .

, , , ( ) , , . , ( ), , ( → , → ).

, , , .

, / .

+2

Source: https://habr.com/ru/post/1016355/


All Articles