Android-如何在一个布局中显示拆分两个StreetView

时间:2015-11-27 12:36:11

标签: java android

我尝试在一个布局文件中加载拆分两个StreetView,例如左侧一个streetView,右侧另一个StreetView。一旦运行我的应用程序左侧streetview将被加载但右侧将是黑屏。请找到附加的图像和源代码。

如何解决这个问题。请指导我.. 提前谢谢 enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/map_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/map_container2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:orientation="vertical">

        <fragment
            android:id="@+id/left_fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            class="com.google.android.gms.maps.SupportStreetViewPanoramaFragment" />

        <fragment
            android:id="@+id/right_fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            class="com.google.android.gms.maps.SupportStreetViewPanoramaFragment"
            />
    </LinearLayout>
</LinearLayout>

MyActivity.java

 public class MyActivity extends FragmentActivity
         {
 private StreetViewPanorama mStreetViewPanorama,mStreetViewPanoramaOne;

          @Override
            protected void onCreate(final Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
        SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
                        (SupportStreetViewPanoramaFragment)
                                getSupportFragmentManager().findFragmentById(R.id.left_fragment);
                streetViewPanoramaFragment.getStreetViewPanoramaAsync(
                        new OnStreetViewPanoramaReadyCallback() {
                            @Override
                            public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
                                mStreetViewPanorama = panorama;

                                    mStreetViewPanorama.setPosition("zlUWGaaVhOMAAAQW-bHrpg");

                            }
                        });
     SupportStreetViewPanoramaFragment streetViewPanoramaFragmentOne =
                        (SupportStreetViewPanoramaFragment)
                                getSupportFragmentManager().findFragmentById(R.id.right_fragment);
                streetViewPanoramaFragmentOne.getStreetViewPanoramaAsync(
                        new OnStreetViewPanoramaReadyCallback() {
                            @Override
                            public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
                                mStreetViewPanoramaOne = panorama;

                                    mStreetViewPanoramaOne .setPosition("zlUWGaaVhOMAAAQW-bHrpg");

                            }
                        });

1 个答案:

答案 0 :(得分:1)

Android不支持在一个布局中使用两个StreetView。参考:here