2

I'm trying to draw grids on map only when zoom level is 18. I created grids with below code successfully. But i have one problem when I move map, new grids are created and there position change. You can see that in screenshot in right image I swiped map to left and grid lines are not same. I want fixed grids drawn. Code posted below images. I'm calling below code from onCameraChange listener of GoogleMap. enter image description here

double squareSize = 5.0d; //5.0d == 50feet
final double LONGITUDE_180 = 180.0d;
final double LATITUDE_90 = 90.0d;
final double PI = 3.141592653589793d;

Code removed its confidential.

drawPolyline function to draw single line

private void drawPolyline(LatLng latLng, LatLng latLng2) {
        PolylineOptions polylineOptions = new PolylineOptions();
        polylineOptions.add(latLng, latLng2);
        polylineOptions.color(Color.argb(50, 0, 0, 100));
        polylineOptions.width(3.5f);
        polylineOptions.visible(true);
        polylineOptions.geodesic(true);
        Polyline polyline = googleMap.addPolyline(polylineOptions);

        this.polylines.add(polyline);
    }
Sabeeh
  • 1,478
  • 15
  • 15
William
  • 225
  • 4
  • 21

1 Answers1

1
double squareSize = 5.0d; //5.0d == 50feet

That is not square Size change it to.

double squareSize = 1.0d;

Then it will work fine but grid size will 3 meter as in what3words. To make it 15 meters which is close to 50 feet divide 1546.0d and 37104.0d with 5.

37104.0d is equal 1546.0d * 24.

Better to extract all these values in variable and use them as.

double var1 = 1546.0d / 5;   // replace with value 1546.0
double var2 = var1 * 24; // replace with value 37104.0d

Hope this will help you.

Sabeeh
  • 1,478
  • 15
  • 15