首页 > 移动平台 > 详细

【智能手环APP for Android 】01 百度地图展示行动轨迹

时间:2014-06-03 01:32:35      阅读:400      评论:0      收藏:0      [点我收藏+]

1、效果图示

bubuko.com,布布扣


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>

3、样例数据封装

 

<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>


5、添加图钉图层

<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>

6、填充图钉位置坐标数据

<span style="font-size:18px;">OverlayItem item = new OverlayItem(geoPoint,"","");
			item.setMarker(getResources().getDrawable(
			R.drawable.map_location_icon));
			itemOverlay.addItem(item);</span>

7、添加轨迹图层

<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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!