0

I have a problem. My app uses coordinates to draw a path between subsequent locations: first location to second, second to third, etc. The app has no problems drawing the path but my location have noise and the lines are everywhere. I know that the blue dot on Google Maps is using smoothing algorithms, different location providers, and other adjustments. Can i take the coordinates of this default blue dot? Not normal coordinates without algorithms.

public void onMapReady(GoogleMap map) {

mMap = map;


if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
        == PackageManager.PERMISSION_GRANTED) {
    mMap.setMyLocationEnabled(true);

    lokalizacja();

} else {

    ActivityCompat.requestPermissions(WorkoutActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_LOCATION_REQUEST_CODE);
}


routeOpts = new PolylineOptions()
        .color(Color.BLUE)
        .width(5 /* TODO: respect density! */)
        .geodesic(true);
route = mMap.addPolyline(routeOpts);
route.setVisible(drawTrack);

mMap.setOnMyLocationButtonClickListener(this);
mMap.setOnMyLocationClickListener(this); }

public void lokalizacja() { //Context context = getApplicationContext();

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

locationListener = new LocationListener() {


    @Override
    public void onLocationChanged(Location location) {




        if (routeOpts != null) {                                               
                lat = (float) location.getLatitude();
                lng = (float) location.getLongitude();

            LatLng myLatLng = new LatLng(lat, lng);
            List<LatLng> points = route.getPoints();
            points.add(myLatLng);
            route.setPoints(points);
        }


    }
@Override public void onStatusChanged(String provider, int status, Bundle extras) {

        Log.d("tocos","StatusChanged");
    }

    @Override
    public void onProviderEnabled(String provider) {
        Log.d("tocos","Enabled");
    }

    @Override
    public void onProviderDisabled(String provider) {
        Log.d("tocos","Disabled");
    }
};
  • Hi Szymon, [this answer](https://stackoverflow.com/a/46194663/2148666), that in turn points to the documentation, has good advice on how to reduce noise in user localization information – Nicolás Carrasco-Stevenson Jan 09 '19 at 14:08

1 Answers1

1

I think that what you want is to use the FusedLocationProviderfrom Google Play services instead of the built in LocationManager that comes with the OS. Take a look at this answer that explains it in great detail