Geolocate using HTML 5 Geolocation API and IP geolocation

Wireless Geolocation (HTML 5 Geolocation API) vs. IP Geolocation

It is good that with the introduction of HTML 5, there is now a specification for a Geolocation API. Geolocation is the technology of figuring out where you are in the world. There are many ways to figure out where you are — your IP address, your wireless network connection, which cell tower your phone is talking to, or dedicated GPS hardware that receives latitude and longitude information from satellites in the sky. This article aims to show you what are the things you can do with this new API controlled by web browser client based on wireless geolocation and compare it with the server-side IP geolocation.

Using the traditional Geolocation via IP address

The traditional way of doing Geolocation via IP address using IP2Location’s database is the server-side code will check the detected user IP address against the IP2Location database.

Using the new HTML 5 Geolocation API which checks your network adapter’s MAC address

Now compare it with Geolocation API which is using the Javascript code below. Your web browser must support HTML 5 and you need to grant permission to collect geolocation data.

<div id="GeoAPI"></div>
<script language="Javascript">
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
  doStuff(position.coords.latitude, position.coords.longitude);
  });
}
else {
  if (document.getElementById("GeoAPI")) {
    document.getElementById("GeoAPI").innerHTML = "I'm sorry but geolocation services are not supported by your browser";
    document.getElementById("GeoAPI").style.color = "#FF0000";
  }
}
 
function doStuff(mylat, mylong) {
  if (document.getElementById("GeoAPI")) {
    document.getElementById("GeoAPI").innerHTML = "<iframe style=\"width: 400px; height: 400px\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"//maps.google.com/?ll=" + mylat + "," + mylong + "&z=16&output=embed\"></iframe>";
  }
}
</script>

Comparison

 Wireless GeolocationIP Address Geolocation
TechnologyMAC Address and Signal StrengthIP Address
AccuracyMedium-High (Street level)Medium (City level)
AvailabilityMedium (Depends to Data)High
PrivacyLowMedium
End-user PermissionRequiredNo
Browser CompatibilityHTML 5 and aboveAll

Sample applications using HTML 5 Geolocation

  1. Find points of interest in the user’s area
  2. Annotating content with location information
  3. Show the user’s position on a map
  4. Turn-by-turn route navigation
  5. Alerts when points of interest are in the user’s vicinity
  6. Up-to-date local information
  7. Location-tagged status updates in social networking applications

Sample applications using IP address Geolocation

  1. Display native language and currency
  2. Redirect web pages based on geographical
  3. Digital Rights Management
  4. Prevent password sharing and abuse of service
  5. Reduce credit card fraud
  6. Web log statistics and analysis
  7. Auto-selection of country on forms
  8. Filter access from countries you do not do business with
  9. Geo-targeting for increased sales and click-through
  10. Spam filtering by location

Conclusion

As you can see, the location detected for the HTML 5 Geolocation API could be more accurate when it is actually able to detect your location. Currently, it may not be able to detect all locations yet and not all browsers at present support this Geolocation API.

There is also a privacy issue so you will need to agree to share your current location with the geodata provider, which is currently Google, to be able to utilize this functionality.

On the other hand, the traditional method of Geolocation which checks your IP address is less intrusive at the cost of being less accurate when it comes to dynamic IP addresses.

However, for most developers, it is usually sufficient for their daily needs. IP Geolocation would be the preferred choice of developers who wish to shield their users from having their privacy intruded upon.


THE POWER OF IP GEOLOCATION

Find a solution that fits.


Was this article helpful?

Related Articles