目录
一、简介
二、运行截图
三、设计步骤
首页 php教程 php手册 【Android】第3章(14)路径规划功能

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

Jul 06, 2016 pm 01:30 PM
android 分类 功能 规划 路径

分类: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

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

新报告对传闻中的三星 Galaxy S25、Galaxy S25 Plus 和 Galaxy S25 Ultra 相机升级进行了严厉的评估 新报告对传闻中的三星 Galaxy S25、Galaxy S25 Plus 和 Galaxy S25 Ultra 相机升级进行了严厉的评估 Sep 12, 2024 pm 12:23 PM

最近几天,Ice Universe 不断披露有关 Galaxy S25 Ultra 的详细信息,人们普遍认为这款手机将是三星的下一款旗舰智能手机。除此之外,泄密者声称三星只计划升级一款相机

三星 Galaxy S25 Ultra 泄露了第一张渲染图,传闻中的设计变化被曝光 三星 Galaxy S25 Ultra 泄露了第一张渲染图,传闻中的设计变化被曝光 Sep 11, 2024 am 06:37 AM

OnLeaks 现在与 Android Headlines 合作,首次展示了 Galaxy S25 Ultra,几天前,他试图从他的 X(以前的 Twitter)粉丝那里筹集到 4,000 美元以上的资金,但失败了。对于上下文,嵌入在 h 下面的渲染图像

IFA 2024 | TCL 的 NXTPAPER 14 在性能上无法与 Galaxy Tab S10 Ultra 相媲美,但在尺寸上几乎可以与之媲美 IFA 2024 | TCL 的 NXTPAPER 14 在性能上无法与 Galaxy Tab S10 Ultra 相媲美,但在尺寸上几乎可以与之媲美 Sep 07, 2024 am 06:35 AM

除了发布两款新智能手机外,TCL 还发布了一款名为 NXTPAPER 14 的新 Android 平板电脑,其大屏幕尺寸是其卖点之一。 NXTPAPER 14 采用 TCL 标志性品牌哑光液晶面板 3.0 版本

Vivo Y300 Pro 在 7.69 毫米纤薄机身中配备 6,500 mAh 电池 Vivo Y300 Pro 在 7.69 毫米纤薄机身中配备 6,500 mAh 电池 Sep 07, 2024 am 06:39 AM

Vivo Y300 Pro刚刚全面亮相,它是最薄的中端Android手机之一,配备大电池。准确来说,这款智能手机的厚度仅为 7.69 毫米,但配备了 6,500 mAh 的电池。这与最近推出的容量相同

三星 Galaxy S24 FE 预计将以低于预期的价格推出,有四种颜色和两种内存选项 三星 Galaxy S24 FE 预计将以低于预期的价格推出,有四种颜色和两种内存选项 Sep 12, 2024 pm 09:21 PM

三星尚未就何时更新其 Fan Edition (FE) 智能手机系列提供任何提示。目前来看,Galaxy S23 FE 仍然是该公司的最新版本,于 2023 年 10 月年初推出。

新报告对传闻中的三星 Galaxy S25、Galaxy S25 Plus 和 Galaxy S25 Ultra 相机升级进行了严厉的评估 新报告对传闻中的三星 Galaxy S25、Galaxy S25 Plus 和 Galaxy S25 Ultra 相机升级进行了严厉的评估 Sep 12, 2024 pm 12:22 PM

最近几天,Ice Universe 不断披露有关 Galaxy S25 Ultra 的详细信息,人们普遍认为这款手机将是三星的下一款旗舰智能手机。除此之外,泄密者声称三星只计划升级一款相机

小米红米 Note 14 Pro Plus 上市,成为首款配备 Light Hunter 800 摄像头的高通 Snapdragon 7s Gen 3 智能手机 小米红米 Note 14 Pro Plus 上市,成为首款配备 Light Hunter 800 摄像头的高通 Snapdragon 7s Gen 3 智能手机 Sep 27, 2024 am 06:23 AM

Redmi Note 14 Pro Plus 现已正式成为去年 Redmi Note 13 Pro Plus 的直接后继产品(亚马逊售价 375 美元)。正如预期的那样,Redmi Note 14 Pro Plus与Redmi Note 14和Redmi Note 14 Pro一起成为Redmi Note 14系列的主角。李

iQOO Z9 Turbo Plus:可能增强的系列旗舰产品已开始预订 iQOO Z9 Turbo Plus:可能增强的系列旗舰产品已开始预订 Sep 10, 2024 am 06:45 AM

OnePlus的姐妹品牌iQOO的2023-4年产品周期可能即将结束;尽管如此,该品牌已宣布 Z9 系列的开发尚未结束。它的最终版,也可能是最高端的 Turbo+ 变体刚刚按照预测发布。时间

See all articles