百度地图API制作类似 百度地图的路线导航界面并实现简单的路线规划功能

本文介绍了如何利用百度地图API创建类似百度地图的路线导航界面,包括公交、驾车、步行等模式,并实现了简单的路线规划。通过自定义放大缩小控件提升用户体验,同时借助SlidingUpPanelLayout库实现界面的滑动效果。功能实现中,首先获取用户当前位置,然后针对已知目的地进行路径查询。
摘要由CSDN通过智能技术生成

之前我们讲了怎么在百度地图上设置Marker(如A点。。) 和弹出框(跟随Marker的,Marker移动的时候也是会跟着移动的),接着又觉得百度地图自带的放大缩小不(fei)是(chang)很(de)漂(chou)亮,我们自定义了放大缩小的控件,本篇我们将制作类似百度地图API制作类似百度地图的公交/驾车/行走/查询界面并实现简单的路线规划功能。


先来张截图:


 



这个界面的实现其实是使用的SlidingUpPanelLayout 开源库从而使得可以跟随手指下拉上划:


其实布局也没什么好讲的,自己到百度地图的APK包里扒拉扒拉图片就都有了,哈哈

<?xml version="1.0" encoding="utf-8"?>
<com.jsbtclient.cusViews.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/map_sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoPanelHeight="60dp"
    sothree:umanoShadowHeight="4dp" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <com.baidu.mapapi.map.MapView
            android:id="@+id/map_mapView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:apiKey="vNQtC8sQSODsLGBk01HYaBQt"
            android:clickable="true" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true" >

            <com.jsbtclient.cusViews.ZoomControlView
                android:id="@+id/map_zoomcontrol"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_marginBottom="20dp"
                android:layout_marginRight="15dp" >
            </com.jsbtclient.cusViews.ZoomControlView>

            <ImageView
                android:id="@+id/map_relocation"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left|top"
       
  • 4
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值