CHAPTER 26 CREATING LOCATION-AWARE WEBPAGES USING GEOLOCATION.

Slides:



Advertisements
Similar presentations
The Web Warrior Guide to Web Design Technologies
Advertisements

CHAPTER 30 THE HTML 5 FORMS PROCESSING. LEARNING OBJECTIVES What the three form elements are How to use the HTML 5 tag to specify a list of words’ form.
HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.
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.
Point Mashups Peterson. Icons Info Marker Random Points.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
CHAPTER 31 BROWSER IDENTIFICATION. LEARNING OBJECTIVES What a “hack” is and why Web developers try to avoid them How to determine a browser’s user-agent.
CHAPTER 18 INTEGRATING AUDIO AND VIDEO. LEARNING OBJECTIVES How the HTML 5 and tag pair can be used to include a video file within a webpage How video.
BY LINDA MOHAISEN MIKE ZIELINSKI The Tree Census Project.
HTML5 GEOLOCATION AND SHAREPOINT GEOLOCATION What is Geolocation? How easy it is to use this service? Can we do something without Javascript?
CS 174: Web Programming April 21 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
CHAPTER 1 GETTING STARTED WITH HTML. LEARNING OBJECTIVES How a Web browser downloads and processes an HTML page for display What is the purpose of a Web.
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.
Samuvel Johnson nd MCA B. Contents  Introduction to Real-time systems  Two main types of system  Testing real-time software  Difficulties.
By: Simon Kleinsmith Supervisor: Mr Mehrdad Ghaziasgar Co-supervisor: Mr James Connan.
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.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Set 11: Mashups (emphasis on Google tools) IT452 Advanced Web and Internet Systems.
Programming Games Recap on Google Maps. Creating elements. Dynamic creation of elements (multiple video elements). Geolocation. Classwork/Homework: Catch-up.
PIZZA WEB PAGE May 28, FOR TODAY  Review Vocabulary Words (take out your worksheets!)  Pizza Web Page  Research more tags  Turn in your homework!
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
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.
Wyatt Pearsall November  HyperText Transfer Protocol.
APPX Conference Welcome! Welcome! Agenda – Friday AM  Redmine  Customer/VAR Presentations Mapping customers in Google Earth Mapping customers.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
Web software. Two types of web software Browser software – used to search for and view websites. Web development software – used to create webpages/websites.
Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your.
Session: 19. © Aptech Ltd. 2HTML5 Geolocation and APIs / Session 19  Explain geolocation and its use in HTML5  Explain the Google Maps API  Explain.
GPS (Global Positioning System). Allows you to share your location in real time and locate your friends using smartphones and GPS.
Computer Science and Software Engineering© 2014 Project Lead The Way, Inc. HTML5 Evolving Standards JavaScript.
Human Tracking System Using DFP in Wireless Environment 3 rd - Review Batch-09 Project Guide Project Members Mrs.G.Sharmila V.Karunya ( ) AP/CSE.
Webview and Web services. Web Apps You can make your web content available to users in two ways in a traditional web browser in an Android application,
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
CHAPTER 15 HTML 5 VIDEO AND AUDIO Intro to HTML5 1.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Creating Interfaces Show form validation examples, Hangman. HTML5 with Google Maps API. Add in localStorage. Design pitfalls. Homework: Make proposal for.
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.
INTRODUCTION TO HTML5 New HTML5 User Interface and Attributes.
CHAPTER 13 COMMUNICATING WITH AJAX. LEARNING OBJECTIVES AJAX, which stands for Asynchronous JavaScript and XMLprovides a way for a browser to send and.
Development of Smart Phone Applications Industrial Placement BSc (Honours) in Software Design Joseph Kenny.
Working with DIV Structures, CSS, Webfonts and Templates 9/16/2015Web Development and Interactive Media.
RIA Geo Location. Finding Location modern devices can get location coordinates phones and tablets can use GPS desktops and laptops –often cannot use GPS.
This shows CIS17 and the first day introduction..
Manual Testing Lesson 3 Test Driving your application.
ArcGIS Server Overlays. The “REST” endpoint, v 9.3 or higher: …ArcGIS/rest/servicesArcGIS/rest/services.
Browser Compatibility Testing, using different browsers Conditional Statements.
CONTACTING OTHER SERVERS.
® ® copyright © 2013 Open Geospatial Consortium What HTML5 and REST mean to the Geo community Raj Singh, PhD Open Geospatial Consortium
JavaScript, Sixth Edition
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
丁建文 國立高雄應用科大資管系副教授 兼任計網中心軟體發展組組長 跨平台行動應用軟體開發技術 : HTML5 & Mobile JavaScript Framework 暨南大學.
4.5. Respond to the touch interface 4.6. Code additional HTML5 APIs 4.7. Access device and operating system resources JavaScript Coding for the Touch Interface,
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 Bus Tracker A Google Maps Application. 22 Objectives You will be able to Add an icon to a map created with the Google Maps API. Use Ajax techniques.
CHAPTER 16 SEARCH ENGINE OPTIMIZATION. LEARNING OBJECTIVES How to monitor your site’s traffic What are the pros and cons of keyword advertising within.
Chapter 17 The Need for HTML 5.
Chap 4. Geolocation API.
ISC440: Web Programming 2 Web APIs Google Maps API
CHAPTER 9 APIS. CHAPTER 9 APIS WHAT IS AN API?
Web software.
Geolocation using Google maps
Geolocation using Google maps
HTML Links.
Presented by Ignas Šeškauskas
Geolocation using Google maps
Presentation transcript:

CHAPTER 26 CREATING LOCATION-AWARE WEBPAGES USING GEOLOCATION

LEARNING OBJECTIVES How geoposition services determine a device’s location and the related accuracy of the result How to enable geopositioning support How to test if a browser supports geolocation How to determine a current location using the geoposition API How to support call-back functions within an application How to track movement using the geoposition API How to use the Google Maps API to map a location

HOW GEOPOSITIONING IDENTIFIES YOUR LOCATION

WORKING WITH LATITUDES AND LONGITUDES

ENABLING GEOLOCATION CAPABILITIES As you might expect, many users are not thrilled by having applications with the ability to know where they are at or to track their movements. To increase your privacy, browsers require enabling geolocation services for an application. Normally, you must respond to a browser prompt before the browser allows geolocation software to determine your position.

TESTING FOR BROWSER GEOLOCATION SUPPORT function DisplaySupport() { if (navigator.geolocation) alert("Geolocation supported"); else alert("No geolocation support"); }

UNDERSTANDING CALL-BACK FUNCTIONS Browsers implement geolocation services as an application program interface, or API. To use the API, place JavaScript statements within your HTML files that call specific functions that are built into the API. Often, the API functions perform their processing and then pass back the result to your code by calling a function that you define, which developers refer to as a call- back function.

SIMPLE EXAMPLE function ShowPosition() { if (navigator.geolocation) navigator.geolocation.getCurrentPosition(DisplayResult, DisplayError) else alert("Browser does not support geolocation"); } function DisplayResult(Position) { var message = " Latitude: " + Position.coords.latitude; message += " Longitude: " + Position.coords.longitude; message += " Accuracy: " + Position.coords.accuracy + " meters "; alert(message); } function DisplayError(Error) { var message; switch(Error.code) { case 0: message = "Error retrieving location information"; break; case 1: message = "User prevented location access"; break; case 2: message = "Browser could not retrieve data"; break; case 3: message = "Browser timed out during data retrieval"; break; } alert(Message); }

TRACKING A USER’S POSITION Many phones now support built-in applications that provide real-time driving directions. Rather than repeatedly calling the getCurrentPosition function to implement such processing, simply direct the geolocation software to monitor the user’s location and then notify the application of location changes by using, instead, the watchPosition API function. After you call the watchPosition function, the API will continue to call back a function within your code as their location changes. To turn off the call-back processing, your code must call the clearWatch API method.

INTEGRATING GOOGLE MAPS Across the Web, users make extensive use of the Google Maps website to obtain driving directions. As it turns out, Google provides a JavaScript-based interface that your HTML files can use to integrate the maps into the pages you create. Although Google Maps are not part of HTML 5, I am presenting them here because they fit nicely into the geopositioning processing. Integrating Google maps into an HTML file is easy. To start, link in Google’s JavaScript code that provides their interface to the API: Then, you use a and tag pair to specify a location in your page where you want the map to appear.

MAPPING THE WHITEHOUSE var map; function DisplayMap() { vargeocoder; geocoder = new google.maps.Geocoder(); varmapOptions = { zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP, streetViewControl:true } map = new google.maps.Map(document.getElementById("mapLocation"), mapOptions); var address = "1600 Pennsylvania Blvd, Washington, D.C."; geocoder.geocode( { 'address': address }, ResultsCallBack); } function ResultsCallBack (results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else alert("Geocode was not successful: " + status); }

RESULT

SATELLITE VIEW

STREET VIEW

MAPPING YOUR CURRENT LOCATION var map; function DisplayMap() { if (navigator.geolocation) navigator.geolocation.getCurrentPosition(DisplayResult, DisplayError) else alert("Browser does not support geolocation"); } function DisplayResult(position) { vargeocoder; geocoder = new google.maps.Geocoder(); varmapOptions = { zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP, streetViewControl:true } map = new google.maps.Map(document.getElementById("mapLocation"), mapOptions); varlatlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); geocoder.geocode({'latLng': latlng}, ResultsCallBack); } function ResultsCallBack (results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else alert("Geocode was not successful: " + status); }

MAPPING CURRENT LOCATION CONTINUED function ShowPosition() { if (navigator.geolocation) navigator.geolocation.getCurrentPosition(DisplayResult, DisplayError) else alert("Browser does not support geolocation"); } function DisplayError(Error) { var message; switch(Error.code) { case 0: message = "Error retrieving location information"; break; case 1: message = "User prevented location access"; break; case 2: message = "Browser could not retrieve data"; break; case 3: message = "Browser timed out during data retrieval"; break; } alert(Message); }

REAL WORLD DESIGN – GEOLOCATION API

SUMMARY The use of geolocation changes how webpages interact with users. By determining a user’s location, a page can display more meaningful information, such as nearby stores, restaurants, and more. Today, most mobile phones and hand-held devices provide GPS support. To make it easy for webpages to use geolocation data, HTML provides a geolocation API. This chapter introduced the use of the API. In addition, this chapter presents ways to integrate Google Maps into your pages to provide street maps, satellite photos, and even street-level views of locations.