Table of Contents
一、运行截图
二、设计步骤
Home php教程 php手册 【Android】第3章(20)示例19--全景图HelloWorld

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

Jul 06, 2016 pm 01:30 PM
android Example

分类: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文件夹下添加该文件,然后将代码改为下面的内容:

1

2

3

4

5

6

7

8

9

10

11

<span style="color: #0000ff;"></span><span style="color: #ff00ff;">xml version="1.0" encoding="utf-8"</span><span style="color: #0000ff;">?&gt;</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;">&gt;</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;">/&gt;</span>

<span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">&gt;</span></span></span>

Copy after login

2、添加Demo19PanoHelloWorld.cs文件

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

<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度旋转效果。


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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:23 PM

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Sep 11, 2024 am 06:37 AM

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size Sep 07, 2024 am 06:35 AM

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Sep 07, 2024 am 06:39 AM

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:22 PM

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Sep 12, 2024 pm 09:21 PM

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options

Motorola Razr 50s shows itself as possible new budget foldable in early leak Motorola Razr 50s shows itself as possible new budget foldable in early leak Sep 07, 2024 am 09:35 AM

Motorola Razr 50s shows itself as possible new budget foldable in early leak

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Sep 27, 2024 am 06:23 AM

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera

See all articles