Slide 1

Slide 1 text

Geolocation

Slide 2

Slide 2 text

Aaron Bassett aaronbassett.com twitter.com/aaronbassett

Slide 3

Slide 3 text

“Geolocation is the identification of the real-world geographic location of an Internet-connected computer, mobile device, website visitor or other.” Wikipedia

Slide 4

Slide 4 text

Devices

Slide 5

Slide 5 text

Geolocation API

Slide 6

Slide 6 text

Privacy Have to give permission Can alter accuracy Might reject you Be trustworthy

Slide 7

Slide 7 text

http://bit.ly/please-work

Slide 8

Slide 8 text

Geolocation Demo

for Glasgow Tech Meetup

<!-- map goes here -->

Status: waiting...

download source from Github

function success(position) { var s = document.getElementById('status'); if (s.className == 'success') { // not sure why we're hitting this twice in FF, // I think it's to do with a cached result coming back return; } s.innerHTML = "found you!"; s.className = 'success'; var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var myOptions = { zoom: 15, center: latlng, mapTypeControl: false, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map"), myOptions); var marker = new google.maps.Marker({ position: latlng, map: map, title:"You are here!" }); } function error(msg) { var s = document.getElementById('status'); s.innerHTML = typeof msg == 'string' ? msg : "failed"; s.className = 'error'; } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(success, error); } else { error('not supported'); }

Slide 9

Slide 9 text

Example function success(pos) { alert(pos.coords.latitude+" : "+pos.coords.longitude); } function error(msg) { msg = (typeof msg == 'string') ? msg : "couldn't find you :("; alert(msg); } if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(success, error); } else { error('not supported'); }

Slide 10

Slide 10 text

/* GeoFill by Christian Heilmann Version: 1.1 Homepage: http://icant.co.uk/geofill Copyright (c) 2009, Christian Heilmann Code licensed under the BSD License */

Slide 11

Slide 11 text

In the wild

Slide 12

Slide 12 text

What not to do

Slide 13

Slide 13 text

github.com/aaronbassett/TMU- Geolocation

Slide 14

Slide 14 text

Thank you for listening no hard questions, plzkthnx!