Home > php教程 > php手册 > body text

【Android】第3章(20)示例19--全景图HelloWorld

WBOY
Release: 2016-07-06 13:30:24
Original
1191 people have browsed it

分类:C#、Android、VS2015、百度地图应用; 创建日期:2016-02-04 百度全景图是一种实景地图服务。为用户提供城市、街道和其他环境的360度全景图像,用户可以通过该服务获得如临其境的地图浏览体验。 本示例演示如何利用百度Android全景SDK v2.2实现全景图

分类:C#、Android、VS2015、百度地图应用; 创建日期:2016-02-04

百度全景图是一种实景地图服务。为用户提供城市、街道和其他环境的360度全景图像,用户可以通过该服务获得如临其境的地图浏览体验。

本示例演示如何利用百度Android全景SDK v2.2实现全景图的检索、显示和交互功能,以便清晰方便地展示目标位置的周边环境。

在下一节准备演示较为完整的全景图示例前,这一节先用最简单的入门代码来看一下全景图的实现。

一、运行截图

本示例运行截图如下:

image

二、设计步骤

1、添加demo19_panodemo_Simple.xml文件

在layout文件夹下添加该文件,然后将代码改为下面的内容:

<span style="color: #0000ff;"></span><span style="color: #ff00ff;">xml version="1.0" encoding="utf-8"</span><span style="color: #0000ff;">?></span>
<span style="color: #0000ff;"><span style="color: #800000;">LinearLayout </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
    android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
    android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
    android:orientation</span><span style="color: #0000ff;">="vertical"</span><span style="color: #0000ff;">></span>
  <span style="color: #0000ff;"><span style="color: #800000;">com.baidu.lbsapi.panoramaview.PanoramaView
      </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/panorama"</span><span style="color: #ff0000;">
      android:layout_width</span><span style="color: #0000ff;">="match_parent"</span><span style="color: #ff0000;">
      android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
      android:clickable</span><span style="color: #0000ff;">="true"</span> <span style="color: #0000ff;">/></span>
<span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span></span></span>
Copy after login

2、添加Demo19PanoHelloWorld.cs文件

在SrcSdkDemos文件夹下添加该文件,然后将其内容改为下面的代码:

<span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.App;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Content.PM;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.OS;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Widget;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Lbsapi.Panoramaview;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Lbsapi;
</span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> BdMapV371Demos.SrcSdkDemos
{
    [Activity(Label </span>= <span style="color: #800000;">"</span><span style="color: #800000;">@string/demo_name_panorama_hello</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        ConfigurationChanges </span>= ConfigChanges.Orientation |<span style="color: #000000;"> ConfigChanges.KeyboardHidden,
         ScreenOrientation </span>=<span style="color: #000000;"> ScreenOrientation.Sensor)]
    </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> Demo19PanoHelloWorld : Activity, IMKGeneralListener
    {
        </span><span style="color: #0000ff;">PRivate</span><span style="color: #000000;"> PanoramaView mPanoView;
        </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> BMapManager mBMapManager;
        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnCreate(Bundle savedInstanceState)
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnCreate(savedInstanceState);
            mBMapManager</span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> BMapManager(applicationContext);
            mBMapManager.Init(</span><span style="color: #0000ff;">this</span><span style="color: #000000;">);
            SetContentView(Resource.Layout.demo19_panodemo_Simple);
            mPanoView </span>= FindViewById<panoramaview><span style="color: #000000;">(Resource.Id.panorama);
            </span><span style="color: #0000ff;">var</span> a =<span style="color: #000000;"> MainActivity.HeNanUniversity;
            mPanoView.SetPanorama(a.Longitude,a.Latitude);
        }

        </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> OnGetPermissionState(<span style="color: #0000ff;">int</span><span style="color: #000000;"> p0)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;">由于MainActivity已经验证过key,所以此处不需要添加任何代码</span>
<span style="color: #000000;">        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnPause()
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnPause();
            mPanoView.OnPause();
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnResume()
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnResume();
            mPanoView.OnResume();
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnDestroy()
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnDestroy();
            mPanoView.Destroy();
            mBMapManager.Dispose();
        }
    }
}</span></panoramaview>
Copy after login

3、修改MainActivity.cs文件

在MainActivity.cs文件的demos字段定义中,去掉【示例19】下面的注释。

运行,在模拟器中用鼠标拖放观察360度旋转效果。


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template