我在google maps api v2(
Android)上创建了一条与折线一起创建的路线.我的自定义标记沿着我通过创建线程实现的路线移动.我也得到了演习(左转,右转等).
现在,当我的标记开始移动(汽车图标)时,我希望它转向并浏览路线.我确实设法旋转它,但我想要一个准确的解决方案.现在我硬编码角度,从而旋转我的标记和“setRoation()方法”.然而旋转不是应该的,我不能得到它的动态角度.
请帮忙 !
提前致谢
解决方法
Hey see following code for rotate marker as per location
double oldlat = 19.180237,oldlong = 72.855415; double newlat = 19.180237,newlong = 72.855415; public void rotatemarker() { Location prevLoc = new Location("service Provider"); prevLoc.setLatitude(oldlat); prevLoc.setLongitude(oldlong); Location newLoc = new Location("service Provider"); newLoc.setLatitude(newlat); newLoc.setLongitude(newlong); bearing = prevLoc.bearingTo(newLoc); map.clear(); map.addMarker(new MarkerOptions() .position(new LatLng(newlat,newlong)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)) .anchor(0.5f,0.5f) .rotation(bearing) .flat(true)); oldlong = newlong; }