分类:C#、Android、VS2015、百度地图应用; 创建日期:2016-02-04

3.5 示例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=""
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=""
class="com.baidu.mapapi.map.TextureMapFragment" /> <fragment
android:id="@+id/map2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=""
class="com.baidu.mapapi.map.TextureMapFragment" />
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=""
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=""
class="com.baidu.mapapi.map.TextureMapFragment" /> <fragment
android:id="@+id/map4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=""
class="com.baidu.mapapi.map.TextureMapFragment" />
</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】3.5 示例5--多地图展示的更多相关文章

  1. Android 开发之集成百度地图的定位与地图展示

    app 应用中,大多数应用都具有定位功能,百度定位就成了开发人员的集成定位功能的首选,近期也在做定位功能,可是发现百度真是个大坑啊, sdk 命名更新了,相关代码却不更新,害得我花费了非常长时间来研究 ...

  2. LBS数据分析:使用地图展示统计数据——麻点图与麻数图

    作为一个LBS的APP,都获得了用户经纬度,也都使用了友盟统计.google ana等等统计分析系统,不过没有地图展示功能,不能进行直观的展示. 友盟统计.google ana等系统是总体数据统计,无 ...

  3. 【iOS】7.4 定位服务->3.1 地图框架MapKit 功能1:地图展示

    > 本文并非最终版本,如果想要关注更新或更正的内容请关注文集,联系方式详见文末,如有疏忽和遗漏,欢迎指正. --- > 本文相关目录: ================== 所属文集:[[ ...

  4. Android 组件化/模块化之路——在展示层搭建MVP结构

    Android 组件化/模块化之路——在展示层搭建MVP结构 什么是MVP Model–View–Presenter (MVP) 源于 Model–View–Controller (MVC) 的结构设 ...

  5. 基于MySQL + Node.js + Leaflet的离线地图展示,支持百度、谷歌、高德、腾讯地图

    1. 基本说明 本项目实现了离线展示百度.谷歌.高德.腾讯地图.主要功能如下: 实现了地图瓦片图下载.存储.目前支持存储至MySQL Node.js服务调用MySQL中的瓦片图 Leaflet展示地图 ...

  6. openlayers4 入门开发系列之地图展示篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  7. Echarts地图展示及属性分析

    Echarts,一个效果非常棒的可视化库,可以生产各种图表,动态展示,附上官方网址:http://www.echartsjs.com/index.html 之前带本科实习时有同学用过,狗哥的博客也用这 ...

  8. SkylineGlobe Android 开发 面积计算示例代码

    SkylineGlobe Android 开发 面积计算示例代码: 如果之前熟悉SkylineGlobe桌面端的二次开发,看这些代码应该不难理解. package com.skyline.terrae ...

  9. Android vcard使用示例,生成vcf文件

     Android vcard使用示例,生成vcf文件 我们备份手机联系人时,导出到SD卡时,会在SD卡中生成一个vcf文件,用于保存联系人姓名,手机号码. vCard 规范容许公开交换个人数据交换 ( ...

随机推荐

  1. IO介绍

    IO在计算机中指Input/Output,也就是输入和输出.由于程序和运行时数据是在内存中驻留,由CPU这个超快的计算核心来执行,涉及到数据交换的地方,通常是磁盘.网络等,就需要IO接口. 比如你打开 ...

  2. 【树莓派】制作树莓派所使用的img镜像(一)

    最近一直在折腾树莓派,前几天装了10台设备,最近又来了15台开发板子.基本每台设备都需要进行如下操作: 1.安装树莓派OS,并配置键盘.时区.语言编码格式等: 2.新增组.用户.配置静态IP地址: 3 ...

  3. Linux软件安装方法

    常用的两种软件安装方法: 1.RPM软件安装 rpm -qi 软件名 查询 rpm -ivh *.rpm 安装 rpm -e 软件名 卸载 系统自带的一些rpm包在系统镜像的Server文件夹里,需要 ...

  4. Android Studio怎样加入工程(project)为library(针对非gradle)

    这篇文章还是针对非gradle build的project,gradle build有一些区别.在Eclipse要引用别的project为本project的library非常easy,可是在Andro ...

  5. MySQL常见架构的应用

    MySQL 的架构设计 MySQL 架构一定要结合前台业务来设计.优化,所以不管是哪种架构.根据业务要求组合成符合需求的即是最好的.不能泛泛而谈同时.也必须注意数据的安全(如ipsec,ssh,vpn ...

  6. 解决 Maven was cached in the local repository, resolution will not be reattempted until the update interv

    问题原因 Maven默认会使用本地缓存的库来编译工程,对于上次下载失败的库,maven会在~/.m2/repository/<group>/<artifact>/<ver ...

  7. Windows 10 Pro_Ent Insider Preview x86 x64 10147中文版激活

    点击激活windows输入密钥:CC6JP-VN67C-8KCJ4-4V48V-HXM9B然后下载附件中的程序解压后运行注销即可激活企业版:在专业版基础上输入升级密钥:CKFK9-QNGF2-D34F ...

  8. Windows 消息机制浅析

    1.       Windows 的历史 中国人喜欢以史为鉴,而事实也确实是,如果你能知道一件事情的来龙去脉,往往可以更容易地理解事物为什么会表现为当前这样的现状.所以,我的介绍性开场白通常会以一段历 ...

  9. Androidmanifest.xml在Android项目中的作用

    以下是一个项目中的AndroidManifest.xml文件: <?xml version="1.0" encoding="utf-8"?> < ...

  10. 基于JavaScript 声明全局变量的三种方式

    本文转自脚本之家:http://www.jb51.net/article/36548.htm JS中声明全局变量主要分为显式声明或者隐式声明下面分别介绍. 声明方式一: 使用var(关键字)+变量名( ...