1.高德地图路线规划
2.根据两个点的经纬度,描绘出两个点的步行路径
3.根据百度的坐标点转换成高德坐标点进行规划路线
4.描绘出我当前的位置
5.描绘出目的地的位置
6.初始化地图,我的位置,进行适当的缩放地图,满足业务需要.
7.直接上代码
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.CameraUpdate;
import com.amap.api.maps2d.CameraUpdateFactory;
import com.amap.api.maps2d.MapView;
import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.amap.api.maps2d.model.CameraPosition;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.maps2d.model.Marker;
import com.amap.api.maps2d.model.MarkerOptions;
import com.amap.api.maps2d.model.Polyline;
import com.amap.api.maps2d.model.PolylineOptions;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.route.BusRouteResult;
import com.amap.api.services.route.DriveRouteResult;
import com.amap.api.services.route.RouteSearch;
import com.amap.api.services.route.RouteSearch.FromAndTo;
import com.amap.api.services.route.RouteSearch.OnRouteSearchListener;
import com.amap.api.services.route.RouteSearch.WalkRouteQuery;
import com.amap.api.services.route.WalkPath;
import com.amap.api.services.route.WalkRouteResult;
import com.amap.api.services.route.WalkStep;
import hyf.wonengkeji.com.util.HyfToast;
public class MainGaoDeMap extends Activity implements OnRouteSearchListener {
private Double position_tv_x;
private Double position_tv_y;
private String name;
private Double x;
private Double y;
//地图控件
private AMap aMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_gao_de_map);
//初始化接受数据
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
position_tv_x = (Double) bundle.get("position_tv_x");
position_tv_y = (Double) bundle.get("position_tv_y");
name = bundle.getString("name");
x = (Double) bundle.get("x");
y = (Double) bundle.get("y");
//bd_decrypt01(position_tv_x, position_tv_y);
//bd_decrypt02(x, y);
//加载地图
MapView mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);// 此方法必须重写
aMap = mapView.getMap();
aMap.clear();
//初始化我的位置
setMyPosition(position_tv_x, position_tv_y);
//设置目的地的位置
setPositionPoint(name, x, y);
//我的标注点
setMinePositionPoint("我的位置", position_tv_x, position_tv_y, "我的位置");
//绘制线路
setLine(position_tv_x, position_tv_y, x, y);
}
/**
* 初始化我的位置地图
*
* @param x
* @param y
*/
private void setMyPosition(Double x, Double y) {
//初始化点
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(