如何将经度和经度传递给Pasnormastreetview以显示街景

时间:2016-09-28 10:30:16

标签: android google-maps

这是观点。在这里,我添加了StreetViewPanormaFragment



<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/street_view_panorama_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.soulsystem_4.myapplication.MapsActivity"
    class="com.google.android.gms.maps.StreetViewPanoramaFragment"/>
&#13;
&#13;
&#13;

这是我想要传递该视图的纬度和经度的类。如何通过。

&#13;
&#13;
    private static final String EXTRA_LONG = "current_long";
    private static final String EXTRA_LAT = "current_lat";
    private static final String EXTRA_BEARING = "current_bearing";
    private static final String EXTRA_TILT = "current_tilt";
    private static final String EXTRA_ZOOM = "current_zoom";

    private GoogleApiClient mLocationClient;
    private Location mCurrentLocation;
    private float mBearing;
    private float mTilt;
    private float mZoom;

    private StreetViewPanorama mPanorama;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.street_view_panorama_fragment);
        mapFragment.getMapAsync(this);
    }
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng(-34, 151);
        mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    }

    @Override
    public void onConnected(@Nullable Bundle bundle) {

    }

    @Override
    public void onConnectionSuspended(int i) {

    }

    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

    }
}
&#13;
&#13;
&#13;

我只想要街景视图,我将传递给该视图。

1 个答案:

答案 0 :(得分:0)

私有静态最终LatLng SYDNEY =新LatLng(-33.87365,151.20689);

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

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

}