Android地图控件之多地图展示

Android地图控件之多地图展示,第1张

概述一、简介 地图控件自v2.3.5版本起,支持多实例,即开发者可以在一个页面中建立多个地图对象,并且针对这些对象分别 *** 作且不会产生相互干扰。

一、简介 
地图控件自v2.3.5版本起,支持多实例,即开发者可以在一个页面中建立多个地图对象,并且针对这些对象分别 *** 作且不会产生相互干扰。
 文件名:Demo04MultiMapVIEw.cs
 简介:介绍多MapVIEw的使用
 详述:在一个界面内,同时建立四个TextureMapVIEw控件;
 二、示例
 1、运行截图
在x86模拟器中的运行效果如下:  

在上一节例子的基础上,只需要再增加下面的步骤即可。

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"    />  <fragment   androID:ID="@+ID/map2"   androID:layout_wIDth="match_parent"   androID:layout_height="match_parent"   androID:layout_weight="1"    /> </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"    />  <fragment   androID:ID="@+ID/map4"   androID:layout_wIDth="match_parent"   androID:layout_height="match_parent"   androID:layout_weight="1"    /> </linearLayout></linearLayout> 

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{ /// <summary> /// 在一个Activity中展示多个地图 /// </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()),

运行观察结果。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。

总结

以上是内存溢出为你收集整理的Android地图控件之多地图展示全部内容,希望文章能够帮你解决Android地图控件之多地图展示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1149149.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存