1、效果图示
2、行动轨迹数据
<span style="font-size:18px;">[
{
"LocationX":"121.42619",
"LocationY":"31.186655"
},
{
"LocationX":"121.42694",
"LocationY":"31.187215"
},
{
"LocationX":"121.425961666667",
"LocationY":"31.187475"
},
{
"LocationX":"121.425641666667",
"LocationY":"31.1873733333333"
}
]</span>
<span style="font-size:18px;">// 测试数据
DataDeviceLocation deviceLocation1 = new DataDeviceLocation();
deviceLocation1.setLocationX("121.42619");
deviceLocation1.setLocationY("31.186655");
DataDeviceLocation deviceLocation2 = new DataDeviceLocation();
deviceLocation2.setLocationX("121.42694");
deviceLocation2.setLocationY("31.187215");
DataDeviceLocation deviceLocation3 = new DataDeviceLocation();
deviceLocation3.setLocationX("121.425961666667");
deviceLocation3.setLocationY("31.187475");
DataDeviceLocation deviceLocation4 = new DataDeviceLocation();
deviceLocation4.setLocationX("121.425641666667");
deviceLocation4.setLocationY("31.1873733333333");
locations.add(deviceLocation4);
locations.add(deviceLocation3);
locations.add(deviceLocation2);
locations.add(deviceLocation1);</span>
4、坐标转换 —— GPS WGS84坐标转百度坐标
<span style="font-size:18px;">geoPoint = CoordinateConvert .fromWgs84ToBaidu(new GeoPoint( (int) (Double.valueOf(locations.get(i) .getLocationY()) * 1E6), (int) (Double .valueOf(locations.get(i) .getLocationX()) * 1E6)));</span>
<span style="font-size:18px;"> OverlayTest itemOverlay = new OverlayTest(getResources().getDrawable( R.drawable.map_location_icon), mMapView); mMapView.getOverlays().clear(); mMapView.getOverlays().add(itemOverlay);</span>
<span style="font-size:18px;">OverlayItem item = new OverlayItem(geoPoint,"",""); item.setMarker(getResources().getDrawable( R.drawable.map_location_icon)); itemOverlay.addItem(item);</span>
<span style="font-size:18px;">MKRoute route = new MKRoute(); GeoPoint[] geoPoints = new GeoPoint[locations.size()]; route.customizeRoute(geoPoints[0], geoPoints[geoPoints.length-1], geoPoints); RouteOverlay routeOverlay = new RouteOverlay(this, mMapView); routeOverlay.setData(route); mMapView.getOverlays().add(routeOverlay);</span>
【智能手环APP for Android 】01 百度地图展示行动轨迹,布布扣,bubuko.com
【智能手环APP for Android 】01 百度地图展示行动轨迹
原文地址:http://blog.csdn.net/gogler/article/details/27549315