C#開(kāi)發(fā)Android百度地圖手機(jī)應(yīng)用程序(多地圖展示)
一、簡(jiǎn)介
地圖控件自v2.3.5版本起,支持多實(shí)例,即開(kāi)發(fā)者可以在一個(gè)頁(yè)面中建立多個(gè)地圖對(duì)象,并且針對(duì)這些對(duì)象分別操作且不會(huì)產(chǎn)生相互干擾。
文件名:Demo04MultiMapView.cs
簡(jiǎn)介:介紹多MapView的使用
詳述:在一個(gè)界面內(nèi),同時(shí)建立四個(gè)TextureMapView控件;
二、示例
1、運(yùn)行截圖
在x86模擬器中的運(yùn)行效果如下:
在上一節(jié)例子的基礎(chǔ)上,只需要再增加下面的步驟即可。
2、添加demo05_multimap.axml文件
在layout文件夾下添加該文件,將其改為下面的代碼:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="5dp" android:layout_weight="1" android:orientation="horizontal" > <fragment android:id="@+id/map1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginRight="5dp" android:layout_weight="1" class="com.baidu.mapapi.map.TextureMapFragment" /> <fragment android:id="@+id/map2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" class="com.baidu.mapapi.map.TextureMapFragment" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" > <fragment android:id="@+id/map3" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginRight="5dp" android:layout_weight="1" class="com.baidu.mapapi.map.TextureMapFragment" /> <fragment android:id="@+id/map4" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" class="com.baidu.mapapi.map.TextureMapFragment" /> </LinearLayout> </LinearLayout>
3、添加Demo05MultiMapView.cs文件
在SdkDemos文件夾下添加該文件,然后將其內(nèi)容改為下面的代碼:
using Android.App; using Android.Content.PM; using Android.OS; using Com.Baidu.Mapapi.Map; using Com.Baidu.Mapapi.Model; namespace BdMapV371Demos.SrcSdkDemos { /// <summary> /// 在一個(gè)Activity中展示多個(gè)地圖 /// </summary> [Activity(Label = "@string/demo_name_multimap", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden, ScreenOrientation = ScreenOrientation.Sensor)] public class Demo05MutiMapView : Activity { private readonly LatLng Geo_BeiJing = new LatLng(39.945, 116.404); private readonly LatLng Geo_ShangHai = new LatLng(31.227, 121.481); private readonly LatLng Geo_GuangZhou = new LatLng(23.155, 113.264); private readonly LatLng Geo_ShenZhen = new LatLng(22.560, 114.064); protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.demo05_multimap); InitMap(); } /// <summary> /// 初始化Map /// </summary> private void InitMap() { MapStatusUpdate u1 = MapStatusUpdateFactory.NewLatLng(Geo_BeiJing); TextureMapFragment map1 = FragmentManager.FindFragmentById<TextureMapFragment>(Resource.Id.map1); map1.BaiduMap.SetMapStatus(u1); MapStatusUpdate u2 = MapStatusUpdateFactory.NewLatLng(Geo_ShangHai); TextureMapFragment map2 = FragmentManager.FindFragmentById<TextureMapFragment>(Resource.Id.map2); map2.BaiduMap.SetMapStatus(u2); MapStatusUpdate u3 = MapStatusUpdateFactory.NewLatLng(Geo_GuangZhou); TextureMapFragment map3 = FragmentManager.FindFragmentById<TextureMapFragment>(Resource.Id.map3); map3.BaiduMap.SetMapStatus(u3); MapStatusUpdate u4 = MapStatusUpdateFactory.NewLatLng(Geo_ShenZhen); TextureMapFragment map4 = FragmentManager.FindFragmentById<TextureMapFragment>(Resource.Id.map4); map4.BaiduMap.SetMapStatus(u4); } } }
4、修改MainActivity.cs文件
在MainActivity.cs文件的demos字段定義中添加下面的代碼。
//示例5--多地圖展示 new DemoInfo<Activity>(Resource.String.demo_title_multimap, Resource.String.demo_desc_multimap, new Demo05MutiMapView()),
以上所述給大家介紹了C#開(kāi)發(fā)Android百度地圖手機(jī)應(yīng)用程序(多地圖展示)的相關(guān)內(nèi)容,希望對(duì)大家有所幫助。
欄 目:C#教程
下一篇:Windows系統(tǒng)中使用C#讀取文本文件內(nèi)容的小示例
本文標(biāo)題:C#開(kāi)發(fā)Android百度地圖手機(jī)應(yīng)用程序(多地圖展示)
本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6704.html
您可能感興趣的文章
- 01-10C#調(diào)用WebService實(shí)例開(kāi)發(fā)
- 01-10實(shí)現(xiàn)ASP.NET無(wú)刷新下載并提示下載完成的開(kāi)發(fā)思路
- 01-10C#開(kāi)發(fā)中的垃圾回收機(jī)制簡(jiǎn)析
- 01-10C#微信開(kāi)發(fā)(服務(wù)器配置)
- 01-10C#使用ImitateLogin模擬登錄百度
- 01-10結(jié)合Visual C#開(kāi)發(fā)環(huán)境講解C#中事件的訂閱和取消訂閱
- 01-10C#微信公眾平臺(tái)開(kāi)發(fā)之高級(jí)群發(fā)接口
- 01-10C#微信公眾平臺(tái)開(kāi)發(fā)之a(chǎn)ccess
- 01-10C#在Unity游戲開(kāi)發(fā)中進(jìn)行多線程編程的方法
- 01-10C#微信開(kāi)發(fā)之微信公眾號(hào)標(biāo)簽管理功能


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10C#通過(guò)反射獲取當(dāng)前工程中所有窗體并
- 01-10關(guān)于ASP網(wǎng)頁(yè)無(wú)法打開(kāi)的解決方案
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10C#實(shí)現(xiàn)txt定位指定行完整實(shí)例
- 01-10WinForm實(shí)現(xiàn)仿視頻 器左下角滾動(dòng)新
- 01-10C#停止線程的方法
- 01-10C#實(shí)現(xiàn)清空回收站的方法
- 01-10C#通過(guò)重寫Panel改變邊框顏色與寬度的
- 01-10C#實(shí)現(xiàn)讀取注冊(cè)表監(jiān)控當(dāng)前操作系統(tǒng)已
隨機(jī)閱讀
- 01-10C#中split用法實(shí)例總結(jié)
- 01-11Mac OSX 打開(kāi)原生自帶讀寫NTFS功能(圖文
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 01-10delphi制作wav文件的方法
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 04-02jquery與jsp,用jquery