首页 > 系统 > Android > 正文

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

2019-11-14 13:28:17
字体:
来源:转载
供稿:网友

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

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

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

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

一、运行截图

本示例运行截图如下:

image

二、设计步骤

1、添加demo19_panodemo_Simple.xml文件

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

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical">  <com.baidu.lbsapi.panoramaview.PanoramaView      android:id="@+id/panorama"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:clickable="true" /></LinearLayout>

2、添加Demo19PanoHelloWorld.cs文件

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

using Android.App;using Android.Content.PM;using Android.OS;using Android.Widget;using Com.Baidu.Lbsapi.Panoramaview;using Com.Baidu.Lbsapi;namespace BdMapV371Demos.SrcSdkDemos{    [Activity(Label = "@string/demo_name_panorama_hello",        ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden,         ScreenOrientation = ScreenOrientation.Sensor)]    public class Demo19PanoHelloWorld : Activity, IMKGeneralListener    {        PRivate PanoramaView mPanoView;        private BMapManager mBMapManager;        protected override void OnCreate(Bundle savedInstanceState)        {            base.OnCreate(savedInstanceState);            mBMapManager= new BMapManager(applicationContext);            mBMapManager.Init(this);            SetContentView(Resource.Layout.demo19_panodemo_Simple);            mPanoView = FindViewById<PanoramaView>(Resource.Id.panorama);            var a = MainActivity.HeNanUniversity;            mPanoView.SetPanorama(a.Longitude,a.Latitude);        }        public void OnGetPermissionState(int p0)        {            //由于MainActivity已经验证过key,所以此处不需要添加任何代码        }        protected override void OnPause()        {            base.OnPause();            mPanoView.OnPause();        }        protected override void OnResume()        {            base.OnResume();            mPanoView.OnResume();        }        protected override void OnDestroy()        {            base.OnDestroy();            mPanoView.Destroy();            mBMapManager.Dispose();        }    }}

3、修改MainActivity.cs文件

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

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表