On Android, just recalibrate the compass to improve accuracy in Google Maps.
Steps

Step 1. Open Google Maps on your Android
This is the icon that represents a map. It is usually found on the Home screen or in the application drawer.

Step 2. Tap the blue dot on the map

Step 3. Choose Calibrate Compass
This option is located in the lower left corner of the screen.

Step 4. Tilt your Android to mimic the diagram shown on the screen
You need to follow the guidance 3 times to properly calibrate the compass.

Step 5. Select OK
Once the compass is calibrated, it will show more accurate results.