Adding Geo-Location to Your Apps

author-image
PCQ Bureau
New Update

You must have wished for a  'guide'  that can live in your pocket everytime
and assist you where ever you go? Be it a new city or a country you would love
to get information related to nearby motels, restaurants, pubs and disco from
this 'guide'.

The good news is it is possible to have one. The Geolocation API used with
your smartphone helps you achieve it. Smart devices like iPhones, Android, etc
have such applications available which detect your current position and provide
you with the information related to your location.

What is geolocation?

Location to a person means context and context means 'higher relevance.'
Location can be represented in different forms. It can be your longitudinal and
latitudinal value, city & state name, street address or a nearby address.

There are many business search APIs present on the web today. To name a few:
Yahoo Local Search API, Yelp API, Localeze, etc. These business APIs help a
small business to grow by providing useful data. Small businesses are tough
since their databases are not complete. With growing APIs and supporting scripts
available on the Internet, web is changing. A lot of companies are adopting
location detection APIs and the change is there for all to see. Google, Firefox,
Opera have already jumped onto it. With Firefox, Safari and few others
supporting location awareness, the day isn't far when other browsers shall do
the same.

Direct Hit!

Applies To: Content developers

USP: Know your visitors by location, and serve them relevant
content Primary Link: www.w3.org/TR/geolocation-API Search
Engine Keywordes:
geolocation, location awareness, map

Sources for detecting geolocation

There are two primary methods of detecting current location of a device:

1.         IP geolocation

2.         Triangulation

  • GPS

  • Wi-Fi

  • Cell Ids (depending upon the service provider)

1. IP Geolocation

In this method, the IP address of the hosting device is used to detect the
current location. This is the easiest method to detect the current location and
is widely available. This method does not require  special technology like
Bluetooth, GPS etc.  in the hosting device. However, it is accurate only till
the city level and not below.

2. Triangulation

This is done using the following techniques:

  • GPS (Global Positioning System) has a coverage radius
    accuracy of 10 m and is highly accurate in open areas. However it does not
    work well in congested areas or indoors. It takes a lot of time to detect
    satellites but works well after it gets a fix. The mobile technology is pretty
    useful for maps and helps in road navigation.

  • Wi-Fi is yet another source of location detection and is
    highly accurate. Its fix time is lesser as compared to GPS. It has a coverage
    radius of 20m, but does not work well in rural areas or where there's no Wi-Fi
    enabled.

  • Cell Ids is the method to detect current location via
    cellular radio. It is not an accurate method to detect location but is widely
    available where there is cellular coverage. It does not take much time for
    first fix and does not require special hardware to detect current location.

The location detected by above methodologies is approximate
and not very accurate. Various companies are working on such kinds of
interactive applications which respond to the user just like a human.

By embedding the geolocation API, within a website you can
search for the precise location of a person or place.

Getting precise information

This is possible by making all future browsers compatible with an API for
retrieving geographic position information associated with a hosting device. The
geographic position information is provided in terms of world geodetic system
co- ordinates. The API provides latitudinal and longitudinal coordinates which
can be used to get city and state information by doing a reverse lookup. If you
are using Mozilla Firefox and you have JavaScript enabled then by using the
following snippet of code you can quickly get your current coordinates. To do
so, create a blank HTML file and paste the following javascript code. The
browser will then ask if you want to share your location or not. If you allow
the browser to share location you will see the current latitude and longitude.



Know your current location

Security issues

Since all future browsers plan to use the API for location awareness of
users, this may lead to privacy concerns. To protect user's privacy an
application must ask a user before sharing his/her location. The API defined in
this specification can be used to retrieve the geographic location of a hosting
device. This can also lead to many security exploits; hence a mechanism should
ensure that no location information is made available without the user's
permission.

Benefits

Someone visiting a foreign city could access a Web application that allows
users to search or browse through a database of tourist attractions. Using the
geolocation API, the Web application has access to a user's approximate position
and is therefore able to rank the search results by proximity to a user's
location. A tour-guide Web application can use the Geolocation API to monitor
the user's position and trigger visual or audio notifications when interesting
places are in the vicinity. An online task management system can trigger
reminders when the user is in the proximity of landmarks that are associated
with certain tasks. A widget-like Web application that shows the weather or news
that are relevant to the user's current area can use the Geolocation API to
register for location updates. If the user's position changes, the widget can
adapt the content accordingly.

Social networking applications

A social network application allows its users to automatically tag their
status updates with location information. It does this by monitoring the user's
position with the Geolocation API. Each user can control the granularity of the
location information (e.g. city or neighbourhood level) that is shared with
other users. A user can also track his network of friends and get real-time
updates about their current location.

XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">







Google Maps JavaScript API Example: Map Markers   







It is worth noting that latitude and longitude detection
via IP address depends upon your ISP and other supporting factors, it may or may
not be accurate.

Sachin Khosla, Digimantra

Stay connected with us through our social media channels for the latest updates and news!

Follow us: