Satellites that shout the time
GPS is a system of satellites orbiting Earth, operated by the United States. Each satellite carries very precise atomic clocks and constantly broadcasts a signal saying, in effect, 'I am here, and the time is exactly this.'
Your phone is only a listener. It never transmits to the satellites; it receives their signals and works out its position from them, which is why checking a map does not tell the satellites anything about you.
Distance from timing
Radio signals travel at the speed of light, so your phone can calculate its distance from a satellite by measuring how long the signal took to arrive. A tiny delay means a huge distance, which is why the clocks must be so exact.
Knowing your distance from one satellite puts you somewhere on a giant sphere around it. Distances from more satellites narrow the spot down — this is called trilateration. In practice a receiver uses signals from at least four satellites, with the fourth helping to correct timing errors.
Why it sometimes gets it wrong
Signals can be blocked or bounced by tall buildings, tunnels, and dense tree cover, which is why your dot on the map sometimes jumps across the street in a city centre. Weather in space and small errors in satellite positions add their own wobble.
Even so, ordinary GPS is typically accurate to within a few metres in open sky — remarkable for a system built from clocks twenty thousand kilometres overhead.

