Yes, GPS works on precise timing coordinated among various satellites that emit timing signals. The satellites are equipped with atomic clocks so that they are all synchronized to the true, accurate time. Then any timing differences from multiple satellites received by the GPS device allows the device to know the precise relative distance it is from the satellites and 'triangulate' its position.
Compasses are often integrated into the GPS device as an aid for orienting a displayed map, routing and other features provided on the GPS device itself. However, the GPS positioning information is not dependent on the earth's magnetic field.