Android Draw polylines with arrow on google map with direction path

前端 未结 1 2034
星月不相逢
星月不相逢 2021-02-09 18:12

I have added polylines but not able to add arrow with direction on google map should be display as below

And when it zoom up, more arrow should be display like below

相关标签:
1条回答
  • 2021-02-09 18:49

    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

    0 讨论(0)
提交回复
热议问题