Discovering distance to a location using javascript
I saw @MrQwest tweet the other day that he was going to be creating something that showed the user something different if they were near a location. He asked Twitter if anyone had done something similar.
Last Christmas I was asked to make a web site for the launch of the latest Rolling Stones’ greatest hits album Grrr. For the launch, the Stones were having a pop up shop on Carnaby Street. Polydor, the label the band is signed to, wanted to be able to allow fans to listen to the album via their mobile phone if they were within a mile of the store while they were shopping. It would also allow fans to listen to the album easily and for free while in the pop up store before they decided to buy the album.
For this example I checked using the new(ish) HTML5 JavaScript geolocation API for the user’s location:
navigator.geolocation.getCurrentPosition(function(result) {
var location =
...