0

i'm trying to draw a circle on a static map by feeding getCircleAsPolyline with Location data and then encode with PolyUtil.encode, according to this SO answer https://stackoverflow.com/a/38100481/1520234.

unfortunately the output is not a circle but something strange like this:

output

can anybody kindly explain me why this happen and if it's possible to get a real circle and if so how?

thanks

EDIT

i apologize for not being very clear, i forgot to mention that actually my getCircleAsPolyline is slightly different from the one i linked since i used SphericalUtil.computeOffset to calculate the coordinates; anyway below is my getCircleAsPolyline function:

private static ArrayList<LatLng> getCircleAsPolyline(Location center, float radius) {
    ArrayList<LatLng> circlePath = new ArrayList<>();
    double step = 5.0;
    double centerLatitude = center.getLatitude();
    double centerLongitude = center.getLongitude();
    for (double angle = 0.0; angle < 360.0; angle += step) {
        LatLng circlePoint = SphericalUtil.computeOffset(
                new LatLng(centerLatitude, centerLongitude),
                radius,
                (90.0 - angle + 360.0) % 360.0
        );
        circlePath.add(circlePoint);
    }
    return circlePath;
}

but result is the one showed in picture

Community
  • 1
  • 1
r08y
  • 125
  • 1
  • 13
  • Do you use Static Maps API in Android app? If so, why don't you use a [Lite mode](https://developers.google.com/maps/documentation/android-api/lite) that show map as a static image? In this case you can draw Circle in lite mode using Circle class – xomena May 03 '17 at 14:44
  • thanks xomena, i didn't know about lite mode, i'll have a look at it. – r08y May 04 '17 at 06:21

1 Answers1

1

For those who'll come here having the same problem, well I simply got it avoiding to encode the polyline: infact as long as I drop PolyUtil.encode and append points as | lat, long | I've been able to draw a perfect circle.

r08y
  • 125
  • 1
  • 13