亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android百度地圖應(yīng)用之圖層展示

 更新時(shí)間:2016年06月14日 10:42:23   作者:rainmj  
這篇文章主要為大家詳細(xì)介紹了Android百度地圖應(yīng)用之圖層展示,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、簡(jiǎn)介
 1、地圖類(lèi)型
 百度地圖Android SDK 3.7.1提供了兩種類(lèi)型的地圖資源(普通矢量地圖和衛(wèi)星圖),開(kāi)發(fā)者可以利用BaiduMap中的MapType屬性(C#)來(lái)設(shè)置地圖類(lèi)型。C#核心代碼如下: 

mMapView = FindViewById<TextureMapView>(Resource.Id.bmapView);
mBaiduMap = mMapView.Map;
//設(shè)置底圖顯示模式:普通地圖
mBaiduMap.MapType = BaiduMap.MapTypeNormal;
//設(shè)置底圖顯示模式:衛(wèi)星地圖
mBaiduMap.MapType = BaiduMap.MapTypeSatellite; 

2、實(shí)時(shí)交通圖
 當(dāng)前,全國(guó)范圍內(nèi)已支持多個(gè)城市實(shí)時(shí)路況查詢,且會(huì)陸續(xù)開(kāi)通其他城市。 
目前有哪些城市具有實(shí)時(shí)交通圖? 
目前(2016-01-27)已有31個(gè)城市開(kāi)通,分別為南京,廣州,重慶,東莞,長(zhǎng)春,臺(tái)州,福州,金華,北京,常州,杭州,溫州,大連,南昌,寧波,沈陽(yáng),中山,珠海,佛山,泉州,石家莊,成都,青島,深圳,武漢,烏魯木齊,長(zhǎng)沙,上海,天津,無(wú)錫,廈門(mén)。之后其他城市還會(huì)陸續(xù)開(kāi)通。
 在地圖上打開(kāi)實(shí)時(shí)路況的C#核心代碼如下: 

mMapView = FindViewById<TextureMapView>(Resource.Id.bmapView);
mBaiduMap = mMapView.Map;
//開(kāi)啟交通圖
mBaiduMap.TrafficEnabled = true; 

3、百度城市熱力圖
 百度地圖SDK繼為廣大開(kāi)發(fā)者開(kāi)放熱力圖本地繪制能力之后,再次進(jìn)一步開(kāi)放百度自有數(shù)據(jù)的城市熱力圖層,幫助開(kāi)發(fā)者構(gòu)建形式更加多樣的移動(dòng)端應(yīng)用。 
百度城市熱力圖的性質(zhì)及使用與實(shí)時(shí)交通圖類(lèi)似,只需要簡(jiǎn)單的接口調(diào)用,即可在地圖上展現(xiàn)樣式豐富的百度城市熱力圖。 
在地圖上開(kāi)啟百度城市熱力圖的C#核心代碼如下: 

mMapView = FindViewById<TextureMapView>(Resource.Id.bmapView);
mBaiduMap = mMapView.Map;
//開(kāi)啟交通圖
mBaiduMap.BaiduHeatMapEnabled = true;


在上一節(jié)例子的基礎(chǔ)上,只需要再增加下面的步驟即可。
 1、添加demo04_layers.axml文件

<?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" >

  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <RadioGroup
      android:id="@+id/RadioGroup"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="2"
      android:orientation="horizontal" >

      <RadioButton
        android:id="@+id/normal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:checked="true"
        android:text="普通圖" />

      <RadioButton
        android:id="@+id/statellite"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="衛(wèi)星圖" />
    </RadioGroup>

    <CheckBox
      android:id="@+id/traffice"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:checked="false"
      android:text="交通圖" />
     
     <CheckBox
      android:id="@+id/baiduHeatMap"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:checked="false"
      android:text="百度城市熱力圖" />
  </LinearLayout>

  <com.baidu.mapapi.map.TextureMapView
    android:id="@+id/bmapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true" />

</LinearLayout>

2、添加Demo04Layers.cs文件 
在SrcSdkDemos文件夾下添加該文件。

using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Widget;
using Com.Baidu.Mapapi.Map;

namespace BdMapV371Demos.SrcSdkDemos
{
  /// <summary>
  /// 演示地圖圖層顯示的控制方法
  /// </summary>
  [Activity(Label = "@string/demo_name_layers",
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden,
    ScreenOrientation = ScreenOrientation.Sensor)]
  public class Demo04Layers : Activity
  {
    //TextureMapView 是地圖主控件
    private TextureMapView mMapView;
    private BaiduMap mBaiduMap;

    protected override void OnCreate(Bundle savedInstanceState)
    {
      base.OnCreate(savedInstanceState);
      SetContentView(Resource.Layout.demo04_layers);

      mMapView = FindViewById<TextureMapView>(Resource.Id.bmapView);
      mBaiduMap = mMapView.Map;
      mBaiduMap.SetMapStatus(MapStatusUpdateFactory.NewLatLng(MainActivity.HeNanUniversity));

      //設(shè)置底圖顯示模式:普通圖
      var normal = FindViewById<RadioButton>(Resource.Id.normal);
      normal.Click += delegate
      {
        mBaiduMap.MapType = BaiduMap.MapTypeNormal;
      };

      //設(shè)置底圖顯示模式:衛(wèi)星圖
      var statellite = FindViewById<RadioButton>(Resource.Id.statellite);
      statellite.Click += delegate
      {
        mBaiduMap.MapType = BaiduMap.MapTypeSatellite;
      };

      //是否顯示交通圖
      var traffice = FindViewById<CheckBox>(Resource.Id.traffice);
      traffice.CheckedChange += (s, e) =>
      {
        mBaiduMap.TrafficEnabled = e.IsChecked;
      };

      //是否顯示熱力圖
      var baiduHeatMap = FindViewById<CheckBox>(Resource.Id.baiduHeatMap);
      traffice.CheckedChange += (s, e) =>
      {
        mBaiduMap.BaiduHeatMapEnabled = e.IsChecked;
      };
    }

    protected override void OnPause()
    {
      mMapView.OnPause();
      base.OnPause();
    }

    protected override void OnResume()
    {
      mMapView.OnResume();
      base.OnResume();
    }

    protected override void OnDestroy()
    {
      mMapView.OnDestroy();
      base.OnDestroy();
    }
  }
}

4、修改MainActivity.cs文件
 在MainActivity.cs文件的demos字段定義中添加下面的代碼。    

     //示例4--圖層展示
      new DemoInfo<Activity>(Resource.String.demo_title_layers,
        Resource.String.demo_desc_layers,
        new Demo04Layers()),

 運(yùn)行。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論