Posts Tagged ‘iPhone’

Geolocation in Firefox 3.5 and the iPhone

Wednesday, July 1st, 2009

Today the Mozilla group released Firefox 3.5. This release has many new features, but one that really interests me is the inbuilt geolocation service. This release also comes hot on the heels of the iPhone OS3.0 software upgrade that also brings inbuilt geolocation to the mobile safari browser. Why is this exciting? They are both based upon the W3C geolocation specifications. I’ve previously written about geolocating using various browser plugins. This is a messy way of doing it and required a lot of code forking to cover the different possibilities. Now we have a standard way of doing this type of thing.

How do we do it?

Let’s start by creating a call to the browsers in built location service. We need to firstly check that the browser supports location services. If it does, then make a call to try and get our location. If we get a successful location we can display the latitude and longitude. We may also get an error. This may occur if the user decides not to share their location or there is an error in the system.


<script type="text/javascript">
// Check in the browser supports native geolocation and make a call to the geolocation service
function findLocation() {
  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(successCallback,errorCallback);
  } else {
    var displayLocation = document.getElementById("location");
    displayLocation.innerHTML = "Your browser doesn't support geolocation services";
  }
}

// Extract the latitude and longitude from the response
function successCallback(position) {
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;
  var displayLocation = document.getElementById("location");
  displayLocation.innerHTML = "latitude: " + latitude + ", longitude:" + longitude;
}

// There was an error
function errorCallback() {
  var displayLocation = document.getElementById("location");
  displayLocation.innerHTML = "Sorry, we couldn't find your location";
}
</script>

We are now able to display our current latitude and longitude – see example 1.

Displaying a map

Now that we have a latitude and longitude it’s much easier to visualise our location if we plot it onto a map.We will keep the same basic code and add some Google Maps script to it.


<script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR_GOOGLE_KEY"></script>
<script type="text/javascript">

// Because we are using a geolocation service we need to make sure sensor=true
google.load("maps", "2", {"other_params":"sensor=true"});

// Check in the browser supports native geolocation and make a call to the geolocation service
function findLocation() {
  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(successCallback,errorCallback);
  } else {
    document.getElementById("location").innerHTML = "Your browser doesn't support geolocation services";
  }
}

// Extract the latitude and longitude from the response and display a map
function successCallback(position) {
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;
  document.getElementById("location").innerHTML = "latitude: " + latitude + ", longitude:" + longitude;

 // Display the map
  var map = new GMap2(document.getElementById('map'));

  // Centre the map around the latitude and longitude
  var latlng = new google.maps.LatLng(latitude, longitude);
  var zoom=16;
  map.setCenter(latlng, zoom);

  // display the default controls
  map.setUIToDefault();

  // Add a marker
  var point = new GLatLng(latitude, longitude);
  map.addOverlay(new GMarker(point));
}

// There was an error
function errorCallback() {
  document.getElementById("location").innerHTML = "Sorry, we couldn't find your location";
}
</script>

Now it is much easier to determine our location by turning the numbers into something visual and meanignful. Try it out in example 2.

These code samples will work for both Firefox 3.5:

Firefox location

And mobile Safari on iPhones and iPod touches running OS3.0

iPhone-location

Now you have the basics of obtaining a latitude and longitude, you can start to use these techniques in your own applications to display locations or items that are relevant to the user in that location.

Tate Liverpool iPhone tours

Thursday, August 14th, 2008

With the recent introduction (for many countries) of Apple’s iPhone, many museums and galleries have been looking at ways they can use the web browser and multimedia player capabilities of the device to enhance the content they deliver.

The Tate Liverpool have made a podcast of their Gustav Klimt exhibition available.  It can be watched from anywhere, but is designed to play on an iPhone or iPod touch at the exhibition. The podcast weighs in at nearly 200Mb so they provide a wi-fi network at the gallery where a user can download it once they arrive or a user can hire an iPod touch.  Given that they have tailored the podcast for these devices and they have a wi-fi network in place, I wonder why they chose to present the content to mimick a traditional audio tour where you walk up to an object and press the corresponding number on the device – rather than as a web based tour that could use a totally different interface to interact with the artwork? 
 
A user using the Tate iPhone tour

However, the podcast itself has been done very well. It begins with a short introduction, showing a user how to use the device.  For each item, a brief image appears and then the screen goes blank while the narration occurs to allow the visitor to focus on the actual work of art, rather than the video screen.  Towards the end of each items file, videos, stills or interviews are presented as secondary content to enhance what the user has already learnt.

The tour appears to be working for the gallery. Will Gompertz, director of Tate Media, stated that the average visit time increased from 45 minutes to 3 hours since the tour was introduced.

Being in Australia, it’s a bit hard for me to visit the exhibition and experience it fully.  Although the tour appears to be working for the gallery, it still feels as though there is a bit of a missed opportunity in that it hasn’t exploited the unique interface of the device in the ways it is capable of being used.

Australian iPhone data plans

Thursday, July 10th, 2008

Vodafone, Optus and Telstra have announced their pricing plans for the iPhone here in Australia.  Take a look at a summary of their proposed pricing structures:

Price per month Included voice and TXT Included data
$19 – Optus $50 100Mb
$30 – Optus 3G wireless broadband N/A 1Gb
$35 – Vodafone 3G mobile broadband N/A 5Gb
$45 – Optus 3G wireless broadband N/A 2Gb
$49 – Optus $300 250Mb
$50 – Optus 3G wireless broadband N/A 5Gb
$59 – Optus $350 500Mb
$59 – Telstra (8Gb or 16Gb iPhone) $25 93Mb
$60 – Optus 3G wireless broadband N/A 6Gb
$69 – Vodafone $310 250Mb
$79 – Optus $550 700Mb
$89 – Optus $600 850Mb
$89 – Telstra (8Gb or 16Gb iPhone) $50 107Mb
$99 – Vodafone $600 500Mb
$109 – Telstra (8Gb or 16Gb iPhone) $70 107Mb
$119 – Vodafone $800 500Mb
$129 – Telstra (16Gb iPhone) $90 107Mb
$149 – Optus $1200 1Gb
$169 – Vodafone $1200 1Gb
$179 – Optus $1500 1Gb

I don’t think they understand what this phone is designed for and what makes it different from any other phone out there.  The difference between this phone and every other phone on the market is its ability to handle data.  If I purchase an iPhone, I’m not interested in getting ridiculous amounts of talk time, I’m interested in data.  I’m still going to keep on making $30 of voice calls each month, regardless of what phone I’m using.  Having data plans starting at 256Mb is simply crazy (although you can still get home broadband plans that have similar low amounts).  Given my browsing habits at home (and the fact that I can jump onto a wi-fi network) I could quite easily cope with 1Gb of data for the time being, but when I only make $25-$30 worth of phone calls a month, what is the incentive to sign up for an extra $1000 of calls a month that will just be wasted?

How about a pricing structure based upon the data usage rather than the talk time? For example:

Price per month Included voice and TXT Included data
$50 $200 1Gb
$70 $300 2Gb
$100 $400 2Gb
$150 $600 5Gb

Isn’t this tailoring the plan to suit the device, rather than just regurgitating the same pricing structure that their previous business models have been based on?  As much as I would love an iPhone, I won’t be lining up tomorrow morning.  I’m going to hold off a little and (hopefully) after the initial hype has died down the carriers will begin to offer some more reasonable plans.

Update 10th July 2008: I added in the prices for their 3G mobile internet plans for extra comparison on how poor their data plans really are.

Update 12th July 2008: Added Telstra pricing