首页 > 代码库 > 【智能手环APP for Android 】01 百度地图展示行动轨迹
【智能手环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>
<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>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。