之前我们讲了怎么在百度地图上设置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"