Android Draw polylines with arrow on google map with direction path

岁酱吖の 提交于 2019-12-03 08:20:45
Android Enthusiast

The best way to draw arrowhead is to use 'Marker' to the map and position it the same as the line's end or starting point. You will need to make it flat and set its rotation manually.

Fortunately, Google Maps Utils can help out with computing the heading (rotation).

Just add compile 'com.google.maps.android:android-maps-utils:0.3.4' as a dependency in your build.gradle file

public static void double computeHeading(LatLng from, LatLng to)

Use Double HeadingRotation = SphericalUtil.computeHeading(LatLng from, LatLng to)

Set the value (which is in degrees) as the markers rotation.

The arrowhead could be a simple bitmap, or even better a drawable Shape.

See Also : Google Map Android API Utility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!