Nowadays, mobile devices are commonly equipped with GPS receivers. Because of the many satellites orbiting the earth, courtesy of the U.S. government, you can use a GPS receiver to find your location easily. However, GPS requires a clear sky to work and hence does not always work indoors or where satellites can't penetrate (such as a tunnel through a mountain).
Another effective way to locate your position is through cell tower triangulation. When a mobile phone is switched on, it is constantly in contact with base stations surrounding it. By knowing the identity of cell towers, it is possible to correlate this information into a physical location through the use of various databases containing the cell towers' identities and their exact geographical locations. Cell tower triangulation has its advantages over GPS because it works indoors, without the need to obtain information from satellites. However, it is not as precise as GPS because its accuracy depends on the area you are in. Cell tower triangulation works best in densely populated areas where the cell towers are closely located.
A third method of locating your position is to rely on Wi-Fi triangulation. Rather than connect to cell towers, the device connects to a Wi-Fi network and checks the service provider against databases to determine the location serviced by the provider. Of the three methods described here, Wi-Fi triangulation is the least accurate.
On iOS devices, Apple provides the Core Location ...