HTML and CSS Reference
A longitude coordinate specifies the east-west position of a point on the Earth's surface. Points with
the same longitude lie on lines running from the North Pole to the South Pole. Longitude is an angle that
varies between 0° at the Prime Meridian to 180° toward the east or west.
Latitude and longitude coordinates are specified in decimal/minute/second (DMS) format or decimal
degrees. For example, in DMS format, the latitude of Mumbai is 18° 55' N and the longitude is 72° 54' E. In
decimal format, the same coordinates are represented as 18.91667 and 72.9, respectively. Positive decimal
numbers indicate north-east positions, whereas negative decimal numbers indicate south-west positions.
The Geolocation API uses latitude and longitude values in decimal format.
Sources of Location Information
The Geolocation API doesn't dictate where the location information is to be fetched from. The source of
location information can vary greatly depending on the type of device you're using. For example, a desktop
computer may use an IP address as the source of information, whereas a mobile phone may use GPS-
based location information. The common sources of location information include the following:
• IP address
• Mobile phones (GSM or Code-Division Multiple Access [CDMA])
These location sources are discussed briefly in the following sections.
Using the IP address through which a user is accessing a web application is possibly the oldest way of
determining the user's location. With this technique, the IP address allotted to a user by the Internet
service provider (ISP) is used to detect the origin of requests. This technique is only a guess, rather than a
precise result, because the ISP might be located far from the user's actual location—so, you can't rely on
the location information provided by this technique.
In addition to being widely used, this technique offers the advantage that the IP-detection and
location-finding logic happen in the server-side code. The client browser doesn't come into picture at all.
However, due to its lack of precision, you can't use this technique in situations where a higher degree of
accuracy is expected.
You can use signals from GPS satellite stations located around the globe to determine a user's exact
location. Although GPS gives much more accurate location information than other techniques, it's not well
suited for closed or indoor locations. Another pitfall of using GPS is the associated higher battery
consumption, which may require the user to charge the device frequently.
Using the Wi-Fi technique, the user's location is determined by calculating the distance between Wi-Fi
access points and the user. This technique works well in closed and indoor locations and gives accurate
results. However, it suffers from the disadvantage that Wi-Fi access isn't available everywhere. Especially in