zoukankan      html  css  js  c++  java
  • 【Android】3.19 示例19--全景图HelloWorld

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

  • 相关阅读:
    通过网络方式安装linux的五种方法
    谈FTP服务器攻击技术及其展望 (下)
    谈FTP服务器攻击技术及其展望 (修改中)
    Fedora 14 x64 试用手记
    加固Samba安全三法
    VMWare高可用集群在企业的应用
    Leetcode-1008 Construct Binary Search Tree from Preorder Traversal(先序遍历构造二叉树)
    Leetcode-1006 Clumsy Factorial(笨阶乘)
    Leetcode-1007 Minimum Domino Rotations For Equal Row(行相等的最少多米诺旋转)
    Leetcode-1005 Maximize Sum Of Array After K Negations(K 次取反后最大化的数组和)
  • 原文地址:https://www.cnblogs.com/rainmj/p/5181765.html
Copyright © 2011-2022 走看看