search
Homephp教程php手册【Android】第3章(20)示例19--全景图HelloWorld

分类: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>

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>

3、修改MainActivity.cs文件

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

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


Statement
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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool