我尝试在一个布局文件中加载拆分两个StreetView,例如左侧一个streetView,右侧另一个StreetView。一旦运行我的应用程序左侧streetview将被加载但右侧将是黑屏。请找到附加的图像和源代码。
<?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");
}
});