日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android地图 demo,Android地图控件之多地图展示

發布時間:2025/3/19 Android 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android地图 demo,Android地图控件之多地图展示 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、簡介

地圖控件自v2.3.5版本起,支持多實例,即開發者可以在一個頁面中建立多個地圖對象,并且針對這些對象分別操作且不會產生相互干擾。

文件名:Demo04MultiMapView.cs

簡介:介紹多MapView的使用

詳述:在一個界面內,同時建立四個TextureMapView控件;

二、示例

1、運行截圖在x86模擬器中的運行效果如下:

在上一節例子的基礎上,只需要再增加下面的步驟即可。

2、添加demo05_multimap.axml文件在layout文件夾下添加該文件,將其改為下面的代碼:

xmlns:map="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_marginBottom="5dp"

android:layout_weight="1"

android:orientation="horizontal" >

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

android:id="@+id/map2"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

class="com.baidu.mapapi.map.TextureMapFragment" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:orientation="horizontal" >

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

android:id="@+id/map4"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

class="com.baidu.mapapi.map.TextureMapFragment" />

3、添加Demo05MultiMapView.cs文件在SdkDemos文件夾下添加該文件,然后將其內容改為下面的代碼:

using Android.App;

using Android.Content.PM;

using Android.OS;

using Com.Baidu.Mapapi.Map;

using Com.Baidu.Mapapi.Model;

namespace BdMapV371Demos.SrcSdkDemos

{

///

/// 在一個Activity中展示多個地圖

///

[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();

}

///

/// 初始化Map

///

private void InitMap()

{

MapStatusUpdate u1 = MapStatusUpdateFactory.NewLatLng(Geo_BeiJing);

TextureMapFragment map1 = FragmentManager.FindFragmentById(Resource.Id.map1);

map1.BaiduMap.SetMapStatus(u1);

MapStatusUpdate u2 = MapStatusUpdateFactory.NewLatLng(Geo_ShangHai);

TextureMapFragment map2 = FragmentManager.FindFragmentById(Resource.Id.map2);

map2.BaiduMap.SetMapStatus(u2);

MapStatusUpdate u3 = MapStatusUpdateFactory.NewLatLng(Geo_GuangZhou);

TextureMapFragment map3 = FragmentManager.FindFragmentById(Resource.Id.map3);

map3.BaiduMap.SetMapStatus(u3);

MapStatusUpdate u4 = MapStatusUpdateFactory.NewLatLng(Geo_ShenZhen);

TextureMapFragment map4 = FragmentManager.FindFragmentById(Resource.Id.map4);

map4.BaiduMap.SetMapStatus(u4);

}

}

}

4、修改MainActivity.cs文件

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

//示例5--多地圖展示

new DemoInfo(Resource.String.demo_title_multimap,

Resource.String.demo_desc_multimap,

new Demo05MutiMapView()),

運行觀察結果。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的android地图 demo,Android地图控件之多地图展示的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。