I am developing an app to be used on road while driving, just like Google Maps for Android, the official Google application.
If you set a target and an origin on the google maps app and begin route, it will stick you on road: the arrow marker will be on road, and it kinda looks like a magnet action between your position and the nearest road, so you will never be off-road because you are supposted to be on road.
How is that made? I want to center the map in the user location, but I want it to be "road sticky" and never leaves the road, so I want to have latitude and longitude values on road...
I am using the android maps v2, i've searched arround for a long time but never saw solution to this-
This is my onlocationchanged method:
@Override
public void onLocationChanged(Location location) {
    latitude = location.getLatitude();
    longitude = location.getLongitude();
    debugTv.setText(latitude.toString() + ", " + longitude.toString());
    String msg = "Updated: " + latitude.toString() + ", "
            + longitude.toString();
    Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(new LatLng(latitude, longitude)).zoom(17).tilt(40)
            .build();
    mapa.animateCamera(CameraUpdateFactory
            .newCameraPosition(cameraPosition));
}
Like this, the camera is centering where I am, wich is good, but as the GPS isnt that accurate sometimes, the little marker I have in the center will be off-road sometimes...