首页 >php教程 >php手册 >【Android】第3章(14)路径规划功能

【Android】第3章(14)路径规划功能

WBOY
WBOY原创
2016-07-06 13:30:231069浏览

分类:C#、Android、VS2015、百度地图应用; 创建日期:2016-02-04 一、简介 线路规划支持以下功能: 公交信息查询:可对公交详细信息进行查询; 公交换乘查询:根据起、终点,查询策略,进行线路规划方案; 驾车线路规划:提供不同策略,规划驾车路线;(支

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

一、简介

线路规划支持以下功能:

  • 公交信息查询:可对公交详细信息进行查询;
  • 公交换乘查询:根据起、终点,查询策略,进行线路规划方案;
  • 驾车线路规划:提供不同策略,规划驾车路线;(支持设置途经点)
  • 步行路径检索:支持步行路径的规划。

其中驾车线路规划自v3.4.0版本起支持多线路检索结果的能力。

二、运行截图

简介:介绍公交、驾车和步行三种线路规划方法和自设路线方法。

详述:

(1)驾车查询新增路径点查询功能,具体使用方法详见开发者指南路径规划部分,只需重载接口;

(2)自设路线功能演示开发者如何自己设定一条路线,包括如何设定起点、终点、途径站点和路段;

(3)自设路线功能同时也介绍如何在两个Activity之间切换的时候管理Mapview的生命周期;

(4)可自定义路线的起终点图标;

本示例运行截图如下:

image

三、设计步骤

1、添加自定义类【代码太多,就不再粘贴在这里了】

本示例用到的文件很多,主要涉及的是自定义覆盖物的相关类,这些文件都在SrcOverlayUtil文件夹下,除了上一节列出的OverlayManager.cs文件和PoiOverlay.cs外,还包括下面的文件。

(1)BikingRouteOverlay.cs文件

用于显示骑行路线的Overlay,自3.4.0版本起可实例化多个添加在地图中显示。

(2)BusLineOverlay.cs文件

用于显示一条公交详情结果的Overlay。

(3)DrivingRouteOverlay.cs文件

用于显示一条驾车路线的overlay,自3.4.0版本起可实例化多个添加在地图中显示,当数据中包含路况数据时,则默认使用路况纹理分段绘制。

(4)TransitRouteOverlay.cs文件

用于显示换乘路线的Overlay,自3.4.0版本起可实例化多个添加在地图中显示。

(5)WalkingRouteOverlay.cs文件

用于显示步行路线的overlay,自3.4.0版本起可实例化多个添加在地图中显示。

2、添加demo13_routeplan.xml文件

在layout文件夹下添加该文件,然后将代码改为下面的内容:

<span style="color: #0000ff;"></span><span style="color: #ff00ff;">xml version="1.0" encoding="utf-8"</span><span style="color: #0000ff;">?></span>
<span style="color: #0000ff;"><span style="color: #800000;">LinearLayout </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
    android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
    android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
    android:orientation</span><span style="color: #0000ff;">="vertical"</span> <span style="color: #0000ff;">></span>

    <span style="color: #0000ff;"><span style="color: #800000;">LinearLayout
        </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
        android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
        android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
        android:orientation</span><span style="color: #0000ff;">="horizontal"</span> <span style="color: #0000ff;">></span>
        <span style="color: #0000ff;"><span style="color: #800000;">TextView
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/textView1"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="起点:"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"><span style="color: #800000;">EditText
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/start"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:ems</span><span style="color: #0000ff;">="10"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="龙泽"</span> <span style="color: #0000ff;">></span>
            <span style="color: #0000ff;"><span style="color: #800000;">requestFocus </span><span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"></span><span style="color: #800000;">EditText</span><span style="color: #0000ff;">></span>
    <span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span>

    <span style="color: #0000ff;"><span style="color: #800000;">LinearLayout
        </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
        android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
        android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
        android:orientation</span><span style="color: #0000ff;">="horizontal"</span> <span style="color: #0000ff;">></span>
        <span style="color: #0000ff;"><span style="color: #800000;">TextView
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/textView2"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="终点:"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"><span style="color: #800000;">EditText
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/end"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:ems</span><span style="color: #0000ff;">="10"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="西单"</span> <span style="color: #0000ff;">></span>
            <span style="color: #0000ff;"><span style="color: #800000;">requestFocus </span><span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"></span><span style="color: #800000;">EditText</span><span style="color: #0000ff;">></span>
    <span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span>

    <span style="color: #0000ff;"><span style="color: #800000;">LinearLayout
        </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
        android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
        android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
        android:layout_marginBottom</span><span style="color: #0000ff;">="5dip"</span><span style="color: #ff0000;">
        android:layout_marginTop</span><span style="color: #0000ff;">="5dip"</span><span style="color: #ff0000;">
        android:orientation</span><span style="color: #0000ff;">="horizontal"</span> <span style="color: #0000ff;">></span>
        <span style="color: #0000ff;"><span style="color: #800000;">Button
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/drive"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_marginLeft</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_marginRight</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
            android:background</span><span style="color: #0000ff;">="@drawable/button_style"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="驾车搜索"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"><span style="color: #800000;">Button
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/transit"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_marginLeft</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_marginRight</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
            android:background</span><span style="color: #0000ff;">="@drawable/button_style"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="公交搜索"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"><span style="color: #800000;">Button
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/walk"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_marginLeft</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_marginRight</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
            android:background</span><span style="color: #0000ff;">="@drawable/button_style"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="步行搜索"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"><span style="color: #800000;">Button
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/bike"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_marginLeft</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_marginRight</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
            android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
            android:background</span><span style="color: #0000ff;">="@drawable/button_style"</span><span style="color: #ff0000;">
            android:text</span><span style="color: #0000ff;">="骑行搜索"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span>

    <span style="color: #0000ff;"><span style="color: #800000;">RelativeLayout
        </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
        android:layout_width</span><span style="color: #0000ff;">="match_parent"</span><span style="color: #ff0000;">
        android:layout_height</span><span style="color: #0000ff;">="match_parent"</span> <span style="color: #0000ff;">></span>

       <span style="color: #0000ff;"><span style="color: #800000;">com.baidu.mapapi.map.TextureMapView
            </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/map"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
            android:clickable</span><span style="color: #0000ff;">="true"</span> <span style="color: #0000ff;">/></span>

       <span style="color: #0000ff;"><span style="color: #800000;">LinearLayout
            </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:layout_alignParentRight</span><span style="color: #0000ff;">="true"</span><span style="color: #ff0000;">
            android:layout_alignParentTop</span><span style="color: #0000ff;">="true"</span><span style="color: #ff0000;">
            android:layout_alignWithParentIfMissing</span><span style="color: #0000ff;">="false"</span><span style="color: #ff0000;">
            android:layout_marginRight</span><span style="color: #0000ff;">="10dp"</span><span style="color: #ff0000;">
            android:layout_marginTop</span><span style="color: #0000ff;">="10dip"</span><span style="color: #ff0000;">
            android:orientation</span><span style="color: #0000ff;">="vertical"</span> <span style="color: #0000ff;">></span>
            <span style="color: #0000ff;"><span style="color: #800000;">Button
                </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/customicon"</span><span style="color: #ff0000;">
                android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
                android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
                android:layout_marginTop</span><span style="color: #0000ff;">="10dip"</span><span style="color: #ff0000;">
                android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
                android:background</span><span style="color: #0000ff;">="@drawable/button_style"</span><span style="color: #ff0000;">
                android:text</span><span style="color: #0000ff;">="自定义起终点图标"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span>

        <span style="color: #0000ff;"><span style="color: #800000;">LinearLayout
            </span><span style="color: #ff0000;">xmlns:android</span><span style="color: #0000ff;">="http://schemas.android.com/apk/res/android"</span><span style="color: #ff0000;">
            android:layout_width</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:layout_height</span><span style="color: #0000ff;">="wrap_content"</span><span style="color: #ff0000;">
            android:layout_alignParentBottom</span><span style="color: #0000ff;">="true"</span><span style="color: #ff0000;">
            android:layout_alignWithParentIfMissing</span><span style="color: #0000ff;">="false"</span><span style="color: #ff0000;">
            android:layout_centerHorizontal</span><span style="color: #0000ff;">="true"</span><span style="color: #ff0000;">
            android:layout_centerVertical</span><span style="color: #0000ff;">="false"</span><span style="color: #ff0000;">
            android:layout_marginBottom</span><span style="color: #0000ff;">="10dip"</span> <span style="color: #0000ff;">></span>

            <span style="color: #0000ff;"><span style="color: #800000;">Button
                </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/PRe"</span><span style="color: #ff0000;">
                android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
                android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
                android:layout_marginLeft</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
                android:layout_marginRight</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
                android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
                android:background</span><span style="color: #0000ff;">="@drawable/pre_"</span> <span style="color: #0000ff;">/></span>

            <span style="color: #0000ff;"><span style="color: #800000;">Button
                </span><span style="color: #ff0000;">android:id</span><span style="color: #0000ff;">="@+id/next"</span><span style="color: #ff0000;">
                android:layout_width</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
                android:layout_height</span><span style="color: #0000ff;">="fill_parent"</span><span style="color: #ff0000;">
                android:layout_marginLeft</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
                android:layout_marginRight</span><span style="color: #0000ff;">="2dip"</span><span style="color: #ff0000;">
                android:layout_weight</span><span style="color: #0000ff;">="1.0"</span><span style="color: #ff0000;">
                android:background</span><span style="color: #0000ff;">="@drawable/next_"</span> <span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span>
    <span style="color: #0000ff;"></span><span style="color: #800000;">RelativeLayout</span><span style="color: #0000ff;">></span>

<span style="color: #0000ff;"></span><span style="color: #800000;">LinearLayout</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

3、添加Demo13RoutePlan.cs文件

在SrcSdkDemos文件夹下添加该文件,然后将代码改为下面的内容:

<span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.App;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Content.PM;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.OS;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Views;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Widget;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Mapapi.Map;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Mapapi.Model;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Mapapi.Search.Core;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Mapapi.Search.Route;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> BdMapV371Demos.SrcOverlayUtil;

</span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> BdMapV371Demos.SrcSdkDemos
{
    </span><span style="color: #808080;">///</span> <span style="color: #808080;"><summary></summary></span>
    <span style="color: #808080;">///</span><span style="color: #008000;">此demo用来展示如何进行驾车、步行、公交路线搜索并在地图使用RouteOverlay、TransitOverlay绘制,
    </span><span style="color: #808080;">///</span><span style="color: #008000;">同时展示如何进行节点浏览并弹出泡泡。
    </span><span style="color: #808080;">///</span> <span style="color: #808080;"></span>
    [Activity(Label = <span style="color: #800000;">"</span><span style="color: #800000;">@string/demo_name_route</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        ConfigurationChanges </span>= ConfigChanges.Orientation |<span style="color: #000000;"> ConfigChanges.KeyboardHidden,
        ScreenOrientation </span>=<span style="color: #000000;"> ScreenOrientation.Sensor)]
    </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> Demo13RoutePlan : Activity
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">浏览路线节点相关</span>
        Button btnPre = <span style="color: #0000ff;">null</span>;<span style="color: #008000;">//</span><span style="color: #008000;">上一个节点</span>
        Button btnNext = <span style="color: #0000ff;">null</span>;<span style="color: #008000;">//</span><span style="color: #008000;">下一个节点</span>
        <span style="color: #0000ff;">int</span> nodeIndex = -<span style="color: #800080;">2</span>;<span style="color: #008000;">//</span><span style="color: #008000;">节点索引,供浏览节点时使用</span>
        RouteLine route = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
        OverlayManager routeOverlay </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">;
        </span><span style="color: #0000ff;">bool</span> useDefaultIcon = <span style="color: #0000ff;">false</span><span style="color: #000000;">;
        </span><span style="color: #0000ff;">private</span> TextView popupText = <span style="color: #0000ff;">null</span>;<span style="color: #008000;">//</span><span style="color: #008000;">泡泡view

        </span><span style="color: #008000;">//</span><span style="color: #008000;">地图相关,使用MyRouteMapView目的是重写touch事件实现泡泡处理。
        </span><span style="color: #008000;">//</span><span style="color: #008000;">如果不处理touch事件,则无需继承,直接使用TextureMapView即可。</span>
        TextureMapView mMapView = <span style="color: #0000ff;">null</span>;   <span style="color: #008000;">//</span><span style="color: #008000;"> 地图View</span>
        BaiduMap mBaidumap = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
        </span><span style="color: #008000;">//</span><span style="color: #008000;">搜索相关</span>
        RoutePlanSearch mSearch = <span style="color: #0000ff;">null</span>;    <span style="color: #008000;">//</span><span style="color: #008000;"> 搜索模块,也可去掉地图模块独立使用</span>

        <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnCreate(Bundle savedInstanceState)
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.demo13_routeplan);

            </span><span style="color: #008000;">//</span><span style="color: #008000;">初始化地图</span>
            mMapView = FindViewById<texturemapview><span style="color: #000000;">(Resource.Id.map);
            mBaidumap </span>=<span style="color: #000000;"> mMapView.Map;

            btnPre </span>= FindViewById<button><span style="color: #000000;">(Resource.Id.pre);
            btnNext </span>= FindViewById<button><span style="color: #000000;">(Resource.Id.next);
            btnPre.Visibility </span>=<span style="color: #000000;"> ViewStates.Invisible;
            btnNext.Visibility </span>=<span style="color: #000000;"> ViewStates.Invisible;

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理地图点击事件</span>
            mBaidumap.MapClick += (s, e) =><span style="color: #000000;">
            {
                </span><span style="color: #008000;">//</span><span style="color: #008000;">LatLng point = e.P0;
                </span><span style="color: #008000;">//</span><span style="color: #008000;">Toast.MakeText(this, point.ToString(), ToastLength.Long).Show();</span>
<span style="color: #000000;">                mBaidumap.HideInfoWindow();
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">--begin--初始化搜索模块,注册处理事件</span>
            mSearch =<span style="color: #000000;"> RoutePlanSearch.NewInstance();
            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理驾车搜索结果</span>
            mSearch.GetDrivingRouteResult += (s, e) =><span style="color: #000000;">
            {
                </span><span style="color: #0000ff;">var</span> result =<span style="color: #000000;"> e.P0;
                </span><span style="color: #0000ff;">if</span> (result == <span style="color: #0000ff;">null</span> || result.Error !=<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    Toast.MakeText(</span><span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">抱歉,未找到结果</span><span style="color: #800000;">"</span><span style="color: #000000;">, ToastLength.Short).Show();
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.AmbiguousRoureAddr)
                {
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">起终点或途经点地址有岐义,通过result.SuggestAddrInfo属性获取建议查询信息
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">......</span>
                    <span style="color: #0000ff;">return</span><span style="color: #000000;">;
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    nodeIndex </span>= -<span style="color: #800080;">1</span><span style="color: #000000;">;
                    btnPre.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    btnNext.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    route </span>= result.RouteLines[<span style="color: #800080;">0</span><span style="color: #000000;">];
                    DrivingRouteOverlay overlay </span>= <span style="color: #0000ff;">new</span> MyDrivingRouteOverlay(<span style="color: #0000ff;">this</span><span style="color: #000000;">, mBaidumap);
                    routeOverlay </span>=<span style="color: #000000;"> overlay;
                    mBaidumap.MarkerClick </span>+= (sender, args) =><span style="color: #000000;">
                    {
                        </span><span style="color: #008000;">//</span><span style="color: #008000;">......</span>
<span style="color: #000000;">                    };
                    overlay.SetData(result.RouteLines[</span><span style="color: #800080;">0</span><span style="color: #000000;">]);
                    overlay.AddToMap();
                    overlay.ZoomToSpan();
                }
            };
            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理公交搜索结果</span>
            mSearch.GetTransitRouteResult += (s,e) =><span style="color: #000000;">
            {
                </span><span style="color: #0000ff;">var</span> result =<span style="color: #000000;"> e.P0;
                </span><span style="color: #0000ff;">if</span> (result == <span style="color: #0000ff;">null</span> || result.Error !=<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    Toast.MakeText(</span><span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">抱歉,未找到结果</span><span style="color: #800000;">"</span><span style="color: #000000;">, ToastLength.Short).Show();
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.AmbiguousRoureAddr)
                {
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">起终点或途经点地址有岐义,通过以下接口获取建议查询信息
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">result.getSuggestAddrInfo()</span>
                    <span style="color: #0000ff;">return</span><span style="color: #000000;">;
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    nodeIndex </span>= -<span style="color: #800080;">1</span><span style="color: #000000;">;
                    btnPre.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    btnNext.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    route </span>= result.RouteLines[<span style="color: #800080;">0</span><span style="color: #000000;">];
                    TransitRouteOverlay overlay </span>= <span style="color: #0000ff;">new</span> MyTransitRouteOverlay(<span style="color: #0000ff;">this</span><span style="color: #000000;">, mBaidumap);
                    mBaidumap.MarkerClick </span>+= (sender, args) =><span style="color: #000000;">
                    {
                        </span><span style="color: #008000;">//</span><span style="color: #008000;">......</span>
<span style="color: #000000;">                    };
                    routeOverlay </span>=<span style="color: #000000;"> overlay;
                    overlay.SetData(result.RouteLines[</span><span style="color: #800080;">0</span><span style="color: #000000;">]);
                    overlay.AddToMap();
                    overlay.ZoomToSpan();
                }
            };
            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理步行搜索结果</span>
            mSearch.GetWalkingRouteResult += (s, e) =><span style="color: #000000;">
            {
                </span><span style="color: #0000ff;">var</span> result =<span style="color: #000000;"> e.P0;
                </span><span style="color: #0000ff;">if</span> (result == <span style="color: #0000ff;">null</span> || result.Error !=<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    Toast.MakeText(</span><span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">抱歉,未找到结果</span><span style="color: #800000;">"</span><span style="color: #000000;">, ToastLength.Short).Show();
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.AmbiguousRoureAddr)
                {
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">起终点或途经点地址有岐义,通过以下接口获取建议查询信息
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">result.getSuggestAddrInfo()</span>
                    <span style="color: #0000ff;">return</span><span style="color: #000000;">;
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    nodeIndex </span>= -<span style="color: #800080;">1</span><span style="color: #000000;">;
                    btnPre.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    btnNext.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    route </span>= result.RouteLines[<span style="color: #800080;">0</span><span style="color: #000000;">];
                    WalkingRouteOverlay overlay </span>= <span style="color: #0000ff;">new</span> MyWalkingRouteOverlay(<span style="color: #0000ff;">this</span><span style="color: #000000;">, mBaidumap);
                    mBaidumap.MarkerClick </span>+= (sender, args) =><span style="color: #000000;">
                    {
                        </span><span style="color: #008000;">//</span><span style="color: #008000;">......</span>
<span style="color: #000000;">                    };
                    routeOverlay </span>=<span style="color: #000000;"> overlay;
                    overlay.SetData(result.RouteLines[</span><span style="color: #800080;">0</span><span style="color: #000000;">]);
                    overlay.AddToMap();
                    overlay.ZoomToSpan();
                }
            };
            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理骑行搜索结果</span>
            mSearch.GetBikingRouteResult += (s, e) =><span style="color: #000000;">
            {
                </span><span style="color: #0000ff;">var</span> result =<span style="color: #000000;"> e.P0;
                </span><span style="color: #0000ff;">if</span> (result == <span style="color: #0000ff;">null</span> || result.Error !=<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    Toast.MakeText(</span><span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">抱歉,未找到结果</span><span style="color: #800000;">"</span><span style="color: #000000;">, ToastLength.Short).Show();
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.AmbiguousRoureAddr)
                {
                    </span><span style="color: #008000;">//</span><span style="color: #008000;"> 如果起终点或途经点地址有岐义,可通过result.SuggestAddrInfo属性获取建议查询信息
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">......</span>
                    <span style="color: #0000ff;">return</span><span style="color: #000000;">;
                }
                </span><span style="color: #0000ff;">if</span> (result.Error ==<span style="color: #000000;"> SearchResult.ERRORNO.NoError)
                {
                    nodeIndex </span>= -<span style="color: #800080;">1</span><span style="color: #000000;">;
                    btnPre.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    btnNext.Visibility </span>=<span style="color: #000000;"> ViewStates.Visible;
                    route </span>= result.RouteLines[<span style="color: #800080;">0</span><span style="color: #000000;">];
                    BikingRouteOverlay overlay </span>= <span style="color: #0000ff;">new</span> MyBikingRouteOverlay(<span style="color: #0000ff;">this</span><span style="color: #000000;">, mBaidumap);
                    routeOverlay </span>=<span style="color: #000000;"> overlay;
                    mBaidumap.MarkerClick </span>+= (sender, args) =><span style="color: #000000;">
                    {
                        </span><span style="color: #008000;">//</span><span style="color: #008000;">......</span>
<span style="color: #000000;">                    };
                    overlay.SetData(result.RouteLines[</span><span style="color: #800080;">0</span><span style="color: #000000;">]);
                    overlay.AddToMap();
                    overlay.ZoomToSpan();
                }
            };
            </span><span style="color: #008000;">//</span><span style="color: #008000;">--end--初始化搜索模块,注册监听事件

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理【驾车搜素】按钮点击事件</span>
            <span style="color: #0000ff;">var</span> btnDrive = FindViewById<button><span style="color: #000000;">(Resource.Id.drive);
            btnDrive.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                SearchButtonProcess(Resource.Id.drive);
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理【公交搜素】按钮点击事件</span>
            <span style="color: #0000ff;">var</span> btnTransit = FindViewById<button><span style="color: #000000;">(Resource.Id.transit);
            btnTransit.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                SearchButtonProcess(Resource.Id.transit);
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理【步行搜素】按钮点击事件</span>
            <span style="color: #0000ff;">var</span> btnWalk = FindViewById<button><span style="color: #000000;">(Resource.Id.walk);
            btnWalk.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                SearchButtonProcess(Resource.Id.walk);
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理【骑行搜素】按钮点击事件</span>
            <span style="color: #0000ff;">var</span> btnBike = FindViewById<button><span style="color: #000000;">(Resource.Id.bike);
            btnBike.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                SearchButtonProcess(Resource.Id.bike);
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理【自定义起终点图标】按钮点击事件</span>
            <span style="color: #0000ff;">var</span> btnCustomicon = FindViewById<button><span style="color: #000000;">(Resource.Id.customicon);
            btnCustomicon.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                </span><span style="color: #008000;">//</span><span style="color: #008000;">切换路线图标,刷新地图使其生效。注意:起终点图标使用中心对齐。</span>
                <span style="color: #0000ff;">if</span> (routeOverlay == <span style="color: #0000ff;">null</span>) <span style="color: #0000ff;">return</span><span style="color: #000000;">;
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (useDefaultIcon)
                {
                    btnCustomicon.Text </span>= <span style="color: #800000;">"</span><span style="color: #800000;">自定义起终点图标</span><span style="color: #800000;">"</span><span style="color: #000000;">;
                    Toast.MakeText(</span><span style="color: #0000ff;">this</span>,<span style="color: #800000;">"</span><span style="color: #800000;">将使用系统起终点图标</span><span style="color: #800000;">"</span><span style="color: #000000;">, ToastLength.Short).Show();
                }
                </span><span style="color: #0000ff;">else</span><span style="color: #000000;">
                {
                    btnCustomicon.Text </span>= <span style="color: #800000;">"</span><span style="color: #800000;">系统起终点图标</span><span style="color: #800000;">"</span><span style="color: #000000;">;
                    Toast.MakeText(</span><span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">将使用自定义起终点图标</span><span style="color: #800000;">"</span><span style="color: #000000;">, ToastLength.Short).Show();
                }
                useDefaultIcon </span>= !<span style="color: #000000;">useDefaultIcon;
                routeOverlay.RemoveFromMap();
                routeOverlay.AddToMap();
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">处理节点浏览相关的按钮事件</span>
            btnPre.Click += <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                NodeClick(Resource.Id.pre);
            };
            btnNext.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                NodeClick(Resource.Id.next);
            };
        }

        </span><span style="color: #808080;">///</span> <span style="color: #808080;"><summary></summary></span>
        <span style="color: #808080;">///</span><span style="color: #008000;"> 发起路线规划搜索
        </span><span style="color: #808080;">///</span> <span style="color: #808080;"></span>
        <span style="color: #808080;">///</span> <span style="color: #808080;"><param name="id"></span><span style="color: #008000;">按钮的id</span><span style="color: #808080;"></span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> SearchButtonProcess(<span style="color: #0000ff;">int</span><span style="color: #000000;"> id)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;">重置浏览节点的路线数据</span>
            route = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            btnPre.Visibility </span>=<span style="color: #000000;"> ViewStates.Invisible;
            btnNext.Visibility </span>=<span style="color: #000000;"> ViewStates.Invisible;
            mBaidumap.Clear();
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 处理搜索按钮响应示例</span>
            EditText editSt = FindViewById<edittext><span style="color: #000000;">(Resource.Id.start);
            EditText editEn </span>= FindViewById<edittext><span style="color: #000000;">(Resource.Id.end);
            </span><span style="color: #008000;">//</span><span style="color: #008000;">设置起终点信息,对于tranist search 来说,城市名无意义</span>
            PlanNode stNode = PlanNode.WithCityNameAndPlaceName(<span style="color: #800000;">"</span><span style="color: #800000;">北京</span><span style="color: #800000;">"</span><span style="color: #000000;">, editSt.Text);
            PlanNode enNode </span>= PlanNode.WithCityNameAndPlaceName(<span style="color: #800000;">"</span><span style="color: #800000;">北京</span><span style="color: #800000;">"</span><span style="color: #000000;">, editEn.Text);

            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 实际使用中请对起点终点城市进行正确的设定</span>
            <span style="color: #0000ff;">if</span> (id ==<span style="color: #000000;"> Resource.Id.drive)
            {
                mSearch.DrivingSearch(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> DrivingRoutePlanOption()
                    .From(stNode).To(enNode));
            }
            </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (id ==<span style="color: #000000;"> Resource.Id.transit)
            {
                mSearch.TransitSearch(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> TransitRoutePlanOption()
                    .From(stNode).City(</span><span style="color: #800000;">"</span><span style="color: #800000;">北京</span><span style="color: #800000;">"</span><span style="color: #000000;">).To(enNode));
            }
            </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (id ==<span style="color: #000000;"> Resource.Id.walk)
            {
                mSearch.WalkingSearch(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> WalkingRoutePlanOption()
                    .From(stNode).To(enNode));
            }
            </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (id ==<span style="color: #000000;"> Resource.Id.bike)
            {
                mSearch.BikingSearch(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BikingRoutePlanOption()
                    .From(stNode).To(enNode));
            }
        }

        </span><span style="color: #808080;">///</span> <span style="color: #808080;"><summary></summary></span>
        <span style="color: #808080;">///</span><span style="color: #008000;"> 节点浏览示例
        </span><span style="color: #808080;">///</span> <span style="color: #808080;"></span>
        <span style="color: #808080;">///</span> <span style="color: #808080;"><param name="id"></span><span style="color: #008000;">按钮的id</span><span style="color: #808080;"></span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> NodeClick(<span style="color: #0000ff;">int</span><span style="color: #000000;"> id)
        {
            </span><span style="color: #0000ff;">if</span> (nodeIndex 1 || route == <span style="color: #0000ff;">null</span> ||<span style="color: #000000;">
                route.AllStep </span>== <span style="color: #0000ff;">null</span> || nodeIndex ><span style="color: #000000;"> route.AllStep.Count)
            {
                </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;
            }
            </span><span style="color: #008000;">//</span><span style="color: #008000;">设置节点索引</span>
            <span style="color: #0000ff;">if</span> (id == Resource.Id.next && nodeIndex 1<span style="color: #000000;">)
            {
                nodeIndex</span>++<span style="color: #000000;">;
            }
            </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (id == Resource.Id.pre && nodeIndex > <span style="color: #800080;">1</span><span style="color: #000000;">)
            {
                nodeIndex</span>--<span style="color: #000000;">;
            }
            </span><span style="color: #0000ff;">if</span> (nodeIndex 0 || nodeIndex >=<span style="color: #000000;"> route.AllStep.Count)
            {
                </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;
            }

            </span><span style="color: #008000;">//</span><span style="color: #008000;">获取节结果信息</span>
            LatLng nodeLocation = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            </span><span style="color: #0000ff;">string</span> nodeTitle = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            </span><span style="color: #0000ff;">var</span> step =<span style="color: #000000;"> route.AllStep[nodeIndex];
            </span><span style="color: #0000ff;">if</span> (step <span style="color: #0000ff;">is</span><span style="color: #000000;"> DrivingRouteLine.DrivingStep)
            {
                nodeLocation </span>=<span style="color: #000000;"> ((DrivingRouteLine.DrivingStep)step).Entrance.Location;
                nodeTitle </span>=<span style="color: #000000;"> ((DrivingRouteLine.DrivingStep)step).Instructions;
            }
            </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (step <span style="color: #0000ff;">is</span><span style="color: #000000;"> WalkingRouteLine.WalkingStep)
            {
                nodeLocation </span>=<span style="color: #000000;"> ((WalkingRouteLine.WalkingStep)step).Entrance.Location;
                nodeTitle </span>=<span style="color: #000000;"> ((WalkingRouteLine.WalkingStep)step).Instructions;
            }
            </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (step <span style="color: #0000ff;">is</span><span style="color: #000000;"> TransitRouteLine.TransitStep)
            {
                nodeLocation </span>=<span style="color: #000000;"> ((TransitRouteLine.TransitStep)step).Entrance.Location;
                nodeTitle </span>=<span style="color: #000000;"> ((TransitRouteLine.TransitStep)step).Instructions;
            }

            </span><span style="color: #0000ff;">if</span> (nodeLocation == <span style="color: #0000ff;">null</span> || nodeTitle == <span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;
            }
            </span><span style="color: #008000;">//</span><span style="color: #008000;">移动节点至中心</span>
<span style="color: #000000;">            mBaidumap.SetMapStatus(MapStatusUpdateFactory.NewLatLng(nodeLocation));
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> Show popup</span>
            popupText= <span style="color: #0000ff;">new</span> TextView(<span style="color: #0000ff;">this</span><span style="color: #000000;">);
            popupText.SetBackgroundResource(Resource.Drawable.popup);
            popupText.SetTextColor(Android.Graphics.Color.Black);
            popupText.Text </span>=<span style="color: #000000;"> nodeTitle;
            mBaidumap.ShowInfoWindow(</span><span style="color: #0000ff;">new</span> InfoWindow(popupText, nodeLocation, <span style="color: #800080;">0</span><span style="color: #000000;">));
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnRestoreInstanceState(Bundle savedInstanceState)
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnRestoreInstanceState(savedInstanceState);
        }

        </span><span style="color: #008000;">//</span><span style="color: #008000;">定制RouteOverly</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> MyDrivingRouteOverlay : DrivingRouteOverlay
        {
            Demo13RoutePlan routePlanDemo;

            </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> MyDrivingRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) :
                </span><span style="color: #0000ff;">base</span><span style="color: #000000;">(baiduMap)
            {
                </span><span style="color: #0000ff;">this</span>.routePlanDemo =<span style="color: #000000;"> routePlanDemo;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span><span style="color: #000000;"> BitmapDescriptor GetStartMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span><span style="color: #000000;"> BitmapDescriptor GetTerminalMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> MyWalkingRouteOverlay : WalkingRouteOverlay
        {
            Demo13RoutePlan routePlanDemo;
            </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> MyWalkingRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) :
                </span><span style="color: #0000ff;">base</span><span style="color: #000000;">(baiduMap)
            {
                </span><span style="color: #0000ff;">this</span>.routePlanDemo =<span style="color: #000000;"> routePlanDemo;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> BitmapDescriptor GetStartMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> BitmapDescriptor GetTerminalMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> MyTransitRouteOverlay : TransitRouteOverlay
        {
            Demo13RoutePlan routePlanDemo;

            </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> MyTransitRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) :
                </span><span style="color: #0000ff;">base</span><span style="color: #000000;">(baiduMap)
            {
                </span><span style="color: #0000ff;">this</span>.routePlanDemo =<span style="color: #000000;"> routePlanDemo;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span><span style="color: #000000;"> BitmapDescriptor GetStartMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span><span style="color: #000000;"> BitmapDescriptor GetTerminalMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> MyBikingRouteOverlay : BikingRouteOverlay
        {
            Demo13RoutePlan routePlanDemo;
            </span><span style="color: #0000ff;">public</span> MyBikingRouteOverlay(Demo13RoutePlan routePlanDemo, BaiduMap baiduMap) : <span style="color: #0000ff;">base</span><span style="color: #000000;">(baiduMap)
            {
                </span><span style="color: #0000ff;">this</span>.routePlanDemo =<span style="color: #000000;"> routePlanDemo;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> BitmapDescriptor GetStartMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_st);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }

            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> BitmapDescriptor GetTerminalMarker()
            {
                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (routePlanDemo.useDefaultIcon)
                {
                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_en);
                }
                </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            }
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnPause()
        {
            mMapView.OnPause();
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnPause();
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnResume()
        {
            mMapView.OnResume();
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnResume();
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnDestroy()
        {
            mSearch.Destroy();
            mMapView.OnDestroy();
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnDestroy();
        }
    }
}</span></edittext></edittext></button></button></button></button></button></button></button></texturemapview>

4、修改MainActivity.cs

在MainActivity.cs文件的demos字段定义中,去掉【示例13】下面的注释。

运行观察结果。


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn