Google Maps uses the magnetometer of your Android device to determine which direction you are going. To improve the location accuracy of your device, you must calibrate your compass in the Google Maps app. This is how.
Your device needs a magnetometer to make the compass function work, and almost all Android smartphones have it included. You must also install the Google Maps Android app, if it is not yet.
These instructions should work on all recent Android versions.
Direction accuracy check of Google Maps
Before calibrating your compass, check if the direction of your device is accurately reported in the Google Maps app.
Open the Google Maps app on your Android device and search for the blue round icon that indicates your location. If it is not visible, press the circular bullseye icon in the lower right corner.
This will be your location as far as Google Maps understands it. The direction of your device is shown as a blue beam in flashlight style around your circular location icon.
If the radius range is too large, Google Maps will usually ask you to calibrate your compass. If this is not the case, you must calibrate it manually.
Calibrate your Android compass in Google Maps
If Google Maps does not automatically calibrate your compass, you must perform a manual calibration. Open the Google Maps app and make sure that the location icon of your blue circular device is visible.
Tap the location icon to view more information about your location. Tap the "Calibrate compass" button at the bottom.
This will open the compass calibration screen. Your current compass accuracy must be shown below as low, medium, or high.
While holding your device and following the method displayed on the screen, move your phone three times, following an eight figure.
Google Maps will alert you once you have calibrated your device and will return to the app main map screen automatically.
If the calibration process was successful, the range of your directional beam should be reduced, the accuracy of your location during the process improve.