HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.

Slides:



Advertisements
Similar presentations
- Enabling Ubiquitous Positioning and Navigation Through Crowdsourcing
Advertisements

Location based services
Where In The World? GPS Instruction For Teachers By: Krissy Vaux & Mark McBride Tri-Valley H.S. Downs, IL STARS April 8, 2005.
Tracking & Login Data persistence User tracking.
Sensors. Point your phone at the sky, and Google Sky Map tells you which stars you’re looking at. Tilt your phone, and you can control the game you’re.
HTML5 Demo ISYS 350. HTML 5 validation/#.UdytIOLn_zc validation/#.UdytIOLn_zc.
Geo Using a device’s location as an input. Why Because the user might not know where they are Because typing is the worst on small devices.
JavaScript, Third Edition
CHAPTER 26 CREATING LOCATION-AWARE WEBPAGES USING GEOLOCATION.
Geolocation with ColdFusion Oğuz Demirkapı CTO | NicheClick Media.
Context Awareness System and Service SCENE JS Lee 1 Energy-Efficient Rate-Adaptive GPS-based Positioning for Smartphones.
HTML5 GEOLOCATION AND SHAREPOINT GEOLOCATION What is Geolocation? How easy it is to use this service? Can we do something without Javascript?
CHAP 4. GEOLOCATION API.  You can request users to share their location and, if they agree, you can provide them with instructions on how to get to a.
UNIT 10 LINKS AND GEOLOCATION. OBJECTIVES  CO1 Describe various components of the Open Web Platform.  CO2 Create a website using HTML5.  CO3 Create.
Location-Based API 1. 2 Location-Based Services or LBS allow software to obtain the phone's current location. This includes location obtained from the.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Programming Games Recap on Google Maps. Creating elements. Dynamic creation of elements (multiple video elements). Geolocation. Classwork/Homework: Catch-up.
Location based services Using Google Maps v2 etc. in Android apps 1Location based services.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
Location based services
Google Maps API. Static Maps send an HTTP GET request receive an image (PNG, GIF, JPEG) no javascript needed encode params in URL example:
INTRODUCTION TO HTML5 Geolocation. Display a Specific Location with Google Maps  You can use the Google Maps API to display a custom map on your own.
Campus Tour COMP 523 Final Presentation Justin, Paul, Florian.
HTML5 Communication. The Setup Somewhere on the web, a server makes a ”service” available, that we wish to use in a web application The service may offer.
Proglan Session 1. .  HTML5 will be the new standard for HTML.  The previous version of HTML, HTML 4.01, came in The web has changed a lot since.
Campus Tour COMP 523 Midterm Presentation Justin, Paul, Florian.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your.
Phonegap Bridge – Compass API CIS 136 Building Mobile Apps 1.
Session: 19. © Aptech Ltd. 2HTML5 Geolocation and APIs / Session 19  Explain geolocation and its use in HTML5  Explain the Google Maps API  Explain.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
Human Tracking System Using DFP in Wireless Environment 3 rd - Review Batch-09 Project Guide Project Members Mrs.G.Sharmila V.Karunya ( ) AP/CSE.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
Creating Interfaces Show form validation examples, Hangman. HTML5 with Google Maps API. Add in localStorage. Design pitfalls. Homework: Make proposal for.
CMPE Senior Design Project Group Members: Jose A Montoya (CMPE) Carlos Olvera (CSCI)
FriendFinder Location-aware social networking on mobile phones.
Phonegap Bridge – Device, Network, Console, Geolocation API’s CIS 136 Building Mobile Apps 1.
FriendFinder Location-aware social networking on mobile phones.
Once, Only Once, and In the Right Place: Gathering Location Data for the 2020 Census Jennifer Hunter Childs Center for Survey Measurement Research and.
RIA Geo Location. Finding Location modern devices can get location coordinates phones and tablets can use GPS desktops and laptops –often cannot use GPS.
Rich Internet Applications 9. HTML 5 and RIAs. HTML 5 Standard currently under development by W3C Aims to improve the language with support for the latest.
Project IIa GPS Jeff Houston Jeff Filson Tim Culbreth Jennifer Martin.
JavaScript, Sixth Edition
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
HTML5 Demo ISYS 350. HTML 5 validation/#.UdytIOLn_zc validation/#.UdytIOLn_zc.
Location based services 1. Some location-based services available in Android Geo-coding – Address -> location Reverse geo-coding – Location -> address(es)
Industry case study: Data Eric Brumer 2/19/2014. Agenda Belltower Books Belltower Books Trucking: backend & frontend Google maps & javascript.
1. 2 Android location services Determining a device’s current location Tracking device movements Proximity alerts.
Chap 4. Geolocation API.
Mobile Computing CSE 40814/60814 Spring 2017.
CSE 154 Lecture 11: AJAx.
Google APIs and Facebook API
CHAPTER 9 APIS. CHAPTER 9 APIS WHAT IS AN API?
Tracking and Booking Taxi
Geolocation using Google maps
Sensors, maps and fragments:
Global Positioning System
Mobile Computing CSE 40814/60814 Spring 2018.
CSE 154 Lecture 11: AJAx.
HTML5 Geolocation 11/12/2018 Copyright © Carl M. Burnett.
CSE 154 Lecture 22: AJAX.
Geolocation using Google maps
HTML Level II (CyberAdvantage)
Session V HTML5 APIs - HTML5 Geolocation
Presented by Ignas Šeškauskas
CIS 136 Building Mobile Apps
Device,Network, Vibration, Console, Accelerometer
Geolocation using Google maps
Presentation transcript:

HTML 5 – GeoLocation and Maps

Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude (east/west) – Altitude (in meters) Usually, we are only interested in lat/lon Smørum: ,

Geolocation API Why is a users location interesting…? Already exists a wealth of location-oriented applications, particularly interesting for mobile applications – ”Where is the nearest xxx…?” – ”How long was my bike trip…?” – ”Where are my kids right now…?

Geolocation API How can a device know its location…? Device-specific – GPS – IP Address – WiFi – Cell Phone towers

Geolocation API GPS – Global Positioning System – Satellite-based – Uses triangulation – Precision? ≈10 meter – GPS device available in (almost) all modern mobile devices – Can have problems indoors – Somewhat slow to ”kick in”

Geolocation API IP Address – Lookup-based, maps IP to a location – Robust, fast, works everywhere – Precision? Depends… Can be anything from very accurate to ”city-level” – May resolve to e.g. ISP, company…

Geolocation API WiFi – Based on Wireless Network lookup – Uses triangulation – Precision? Depends… – Fast, works indoors – Depends entirely on the availability of wireless networks

Geolocation API Cell Phone towers – Based on Cell phone tower lookup – Uses triangulation – Precision? Depends… Best precision lower than e.g. GPS – Fast, works indoors (and outdoors) – Depends entirely on the availability of cell phone towers

Geolocation API Good news – you do not need to worry about the device-specific details You can obtain – The location itself – The estimated accurary – The time at which the location was retrieved

Geolocation API How do you get hold of your location? Through the Geolocation API (JavaScript)! – All browsers support a global navigator object – If the navigator object contains a geolocation property, the browser supports Geolocation

Geolocation API if (navigator.geolocation) { // Do Geolocation stuff } else { // No Geolocation support }

Geolocation API I have Geolocation support, now what…? On the geolocation object, you can call the getCurrentPosition method Note that the getCurrentPosition method takes a callback method as a parameter! The callback method must take a position object as a parameter

Geolocation API function handleLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; // Do stuff with latitude and longitude } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(handleLocation); } else { // No Geolocation support }

Geolocation API function showLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; alert("Latitude : " + latitude + " Longitude: " + longitude); } function errorHandler(err) { if(err.code == 1) { alert("Error: Access is denied!"); } else if( err.code == 2) { alert("Error: Position is unavailable!"); }

Geolocation API function getLocation() { if (navigator.geolocation) { // timeout at milliseconds (60 seconds) var options = {timeout:60000}; navigator.geolocation.getCurrentPosition( showLocation, errorHandler, options); } else { alert("Sorry, browser does not support geolocation!"); }

Geolocation API Note that – The callback method does not get called immediately, but when a location is available – The user may have to explicitly permit that a location is retrieved (privacy protection) – You may wish to include an error handler method to gracefully handle errors

Geolocation API When the callback is called, a position object is provided From the position object, we can extract – Latitude – Longitude – Accurary – …(and a bit more)

Geolocation API function handleLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; var accuracy = position.coords.accuracy; // In meters } The given accuracy is within a 95 % confidence interval

Geolocation API What ”options” are available, and what are they good for? – timeout: how long are we willing to wait for an answer (in millisecs). Default is infinite – maximumAge: how old a cached location may be, in order to be acceptable as the ”current” location. Default is 0. – enableHighAccuracy: If more than one ”device” for obtaining a position is available, will we want the most accurate one. Default is false.

Using Maps A very obvious use for a position is to display it on a map This is quite easy to do using the Google Map API A third-party tool, not part of HTML5 as such

Using Maps Steps to use Google Maps – Step 1: Link to the Google Map API, by including the below line in your HTML document:

Using Maps Steps to use Google Maps – Step 2: Given a coordinate (lat/lon) and some option values, create a Map object

Using Maps // We have a global variable referring to a map var map; // Create a ”Google coordinate” var gLatLon = new google.maps.LatLng(lat,lon); // Set up the map options var mapOptions = { zoom: 10, center: gLatLon, mapTypeId: google.maps.MapTypeId.ROADMAP} // Suppose we have a div in the document, with the Id ”map” var mapDiv = document.getElementById(”map”); // Now create the actual map map = new google.maps.Map(mapDiv, mapOptions); // All this could go into the handleLocation method...

Using Maps

Nice, but…where are we? At the center of the map Would be nicer if location was more explicitly indicated We can do this by adding a marker

Using Maps Using a marker requires more code than adding a map… Need to specify – The marker position – Some marker options – Some information window options – An event handler for cliking on the marker Se book for further details

Using Maps

More fun with maps:

Geolocation API You can also also the Geolocation API for tracking a position We can obviously do this ”manually” by repeated calls of getCurrentPosition Somewhat tedious, is ”automated” by using the watchPosition method

Geolocation API getCurrentPosition: calls the callback method once, and is done watchPosition: calls the callback method whenever the position changes, until… …we call the clearWatch method

Geolocation API watchPosition takes the same parameters as getCurrentPosition, but returns an int. This int is the watch identifier When we wish to stop the watch, we must call clearWatch with the watch identifier as argument

Geolocation API If you wish to see location tracking in action – On your mobile phone, go to – Take a walk