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

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>

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>






评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值