How do I get the coordinates of a point at a certain distance from my location?

5

Speak people, I'm making an app, and in an activity of the precise app from my location give a "zoom" in the maps as the user slides a seekBar, according to the image.

I've been thinking of using the Bounds feature in maps, where I can pass two longitudes and latitudes so that maps create a border and zoom.

LatLngBounds bounds = new LatLngBounds.Builder()
                    .include(providerLocation)
                    .include(myLocation)
                    .build();
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, getWidthScreen()-0, getHeightScreen()-0, 190));

My problem is as follows, I can not calculate from my point the latitude of a point x1, a point x2, which would be the reference points.

Thank you for your help!

    
asked by anonymous 07.04.2015 / 14:43

1 answer

6

If you want to calculate a Bounds that has a radius (half diagonal) equal to that indicated by seekBar and your location is in the center, do so.

//Calcula o ponto à distância 'raio' do 'centro*' na direção 45º(canto superior direito)
LatLng norhtEast = SphericalUtil.computeOffset(centro, raio, 45);

//Calcula o ponto à distância 'raio' do 'centro' na direção 225º(canto inferior esquerdo)
LatLng southWest = SphericalUtil.computeOffset(centro, raio, 225);

LatLngBounds bounds = new LatLngBounds(southWest,norhtEast);

Where:

center - LatLng of your position. ray - Distance in meters from center to upper right and bottom left corner of Bounds

    
07.04.2015 / 16:41