How to compute a radius around a point in an Android MapView?

后端 未结 3 792
别跟我提以往
别跟我提以往 2020-12-13 16:26

I have a MapView that I\'m displaying a \"useful radius\" (think accuracy of coordinate) in. Using MapView\'s Projection\'s metersToEquatorPixels, which is admi

相关标签:
3条回答
  • 2020-12-13 16:42
    projection.toPixels(GeoP, pt);
    float radius = projection.metersToEquatorPixels(50);
    

    Try this and see... i used it on my MapRadius and it seems to be working

    0 讨论(0)
  • 2020-12-13 16:49

    So, Google Maps uses a Mercator projection. This means that the further you get from the equator the more distorted the distances become. According to this discussion, the proper way to convert for distances is something like:

    public static int metersToRadius(float meters, MapView map, double latitude) {
        return (int) (map.getProjection().metersToEquatorPixels(meters) * (1/ Math.cos(Math.toRadians(latitude))));         
    }
    
    0 讨论(0)
  • 2020-12-13 16:52
    mMap.addCircle(
        new CircleOptions().center(
            new LatLng(
                bounds.getCenter().latitude, 
                bounds.getCenter().longitude
            )
        )
        .radius(50000)
        .strokeWidth(0f)
        .fillColor(0x550000FF)
    );
    
    0 讨论(0)
提交回复
热议问题