当前位置: 代码迷 >> Android >> 【智能手环APP for Android 】01 百度map展示行动轨迹
  详细解决方案

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

热度:39   发布时间:2016-04-28 05:26:24.0
【智能手环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>






  相关解决方案