It's pretty much never GPS alone, since the GPS chips used in cell phones are inferior to those found in dedicated navigation devices. Cell phones additionally use AGPS (assisted GPS), which is based on triangulation (measuring your location using the 3 cell towers your device is connected to). Other than that locations can be determined using your internet connection, but this is not very accurate.