~bohwaz/blog/

Avec de vrais morceaux de 2.0 !

Custom Geolocation API for Opera (replacing Google)

New Opera version comes with geolocation ability (based on W3C Geolocation API), which is an interesting feature, but as most of the web browsers, they get your location from Google. In other words, each time a page requests your location, the browser makes a request to Google with different datas (wifi networks around you, your IP address, and other stuff) to know where your are. Yeah that sucks, depending on Google for this simple feature is a shame. And you know that all the datas they gather through this service will be recorded and used by Google for various purposes. So, we need more privacy!

Another thing is that on a desktop computer (usually at work), you don't have wifi nor GPS, so your location will be based on your IP address which is not a very accurate way to give your location and most of the time your location will just be the center of the nearest big city. Not very useful. So, we need more accurate location!

Achieving both of those goals is actually very easy.

The first thing is to know what coordinates you want to send to the browser. To find the latitude and longitude you will send to the browser simply find a good location, like on this useful webpage. You can give any location, like for me I gave the location of Strahan in Tasmania. You don't have to give your real location, that's the cool thing.

The second thing is to create a PHP file on some web server you have, the best would be localhost or a web server on your local network. In this file you will copy this:

<?php
$latitude = '-42.16340';
$longitude = '145.31616';

echo '{"location":{"latitude":'.$latitude.',"longitude":'.$longitude.',"accuracy":10.0}}';
?>

Don't forget to replace the latitude and longitude values with the ones you found at step one. Save file.

Now is step three: instructing Opera to request your own geolocation API instead of the Google one. It's quite easy, go to opera:config#Geolocation and replace the Google URL with the one of your PHP script (for me it's http://localhost/geo.php). Hit the Save button.

And now each time a website will request your location, Opera will send him the location *you* gave. And your privacy will be protected from the evil Google company.

You can try and look at your location on the Opera live map.

Of course the best would be that the web browser itself allows you to specify one fixed location instead of requesting an online API... Maybe in the next release of Opera, Firefox and Chrome?

Write a comment
(optional)
(optional)
(mandatory)
  __ _  __                 
 / _(_) \_\__   ___ __ ___ 
| |_| |/ _ \ \ / / '__/ _ \
|  _| |  __/\ V /| | |  __/
|_| |_|\___| \_/ |_|  \___|
                           
(mandatory)

URLs will create links automatically.
Allowed HTML tags: <blockquote> <cite> <pre> <code> <var> <strong> <em> <del> <ins> <kbd> <samp> <abbr>