Geolocation using Google maps

Slides:



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

HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.
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.
Tutorial 14 Working with Forms and Regular Expressions.
CHAPTER 26 CREATING LOCATION-AWARE WEBPAGES USING GEOLOCATION.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 2- JavaScript in Action Modern JavaScript Design And Develop Copyright © 2012 by Larry.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
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?
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
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.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Programming Games Recap on Google Maps. Creating elements. Dynamic creation of elements (multiple video elements). Geolocation. Classwork/Homework: Catch-up.
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
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.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 4-1 of…
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
Tutorial: Using ArcGIS Server and ESRI ArcGIS API for Javascript Peter Sforza March 7, 2013.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
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.
Phonegap Bridge – File System 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.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Phonegap Bridge – Device, Network, Console, Geolocation API’s CIS 136 Building Mobile Apps 1.
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.
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.
1 Using the Google Maps JavaScript API. 2 The Google Maps APIs Permit web applications to use functionality of google maps. Documentation:
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.
XHTML. What Is XHTML? XHTML stands for EXtensible HyperText Markup Language XHTML is almost identical to HTML XHTML is stricter than HTML XHTML is HTML.
Location And Maps Sisoft Technologies Pvt Ltd
Chap 4. Geolocation API.
JavaScript, Sixth Edition
ISC440: Web Programming 2 Web APIs Google Maps API
Google APIs and Facebook API
Web Services application that operates over a network
AnDroid GoogleMaps API
By Dan Gotlund & Eric Acierto
CHAPTER 9 APIS. CHAPTER 9 APIS WHAT IS AN API?
Geolocation using Google maps
Sensors, maps and fragments:
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Week#2 Day#1 Java Script Course
Working with Forms and Regular Expressions
JavaScript: Array, Loop, Data File
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
CIS 136 Building Mobile Apps
Presented by Ignas Šeškauskas
CIS 136 Building Mobile Apps
Device,Network, Vibration, Console, Accelerometer
Device,Network, Vibration, Console, Accelerometer
Web Programming and Design
Presentation transcript:

Geolocation using Google maps CIS 136 Building Mobile Apps

Geolocation Plug-in Makes the app location-aware information about the device's location, such as latitude and longitude Common sources of location information include: Global Positioning System (GPS) location inferred from network signals such as: IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs There is no guarantee that the API returns the device's actual location

navigator.geolocation determine the device's network connection state, and type of connection Has 3 methods getCurrentPosition watchPosition clearWatch Exposes 3 objects Position PositionError coordinates

navigator.geolocation.getCurrentPosition Returns the device's current position to the Success callback with a Position object as the parameter Position object contains the current GPS coordinates Ex: $(document).on("deviceready", function() { navigator.geolocation.getCurrentPosition(success,error); } function success(position) { // gets position object function error(positionerror) //gets PositionError object

Position object Position object has 7 types of coordinate items and a timestamp position.coords.latitude position.coords.longitude position.coords.altitude position.coords.accuracy position.coords.altitudeAccuracy position.coords.heading position.coords.speed position.timestamp Ex:

Position error object Created when an error occurs Codes: code: A predefined error code message: Error message describing the details of the error encountered Codes: PositionError.PERMISSION_DENIED Returned when users do not allow the app to retrieve position information •PositionError.POSITION_UNAVAILABLE Returned when the device is unable to retrieve a position •PositionError.TIMEOUT Returned when the device is unable to retrieve a position within the time specified by the timeout included in geolocationOptions

navigator.geolocation.watchPosition Returns the device's current position when a change in position is detected Returns the position to the Success callback with a Position object as the parameter Position object contains the current GPS coordinates Ex: $document).on("deviceready", function() { watchID = navigator.geolocation.watchPosition(success,error,opts); } function success(position) // gets position object function error(positionerror) //gets PositionError object

navigator.geolocation.watchPosition Gets a watchID that references the watch position interval optional parameters customize the retrieval of the position Timeout - maximum length of time (milliseconds) that is allowed to pass from the call to get until the call to watch, until the success event occurs (number) enableHighAccuracy -By default, the device attempts to retrieve a Position using network-based methods Setting this property to true tells the framework to use more accurate methods, such as satellite positioning. (Boolean) maximumAge: cached position whose age is no greater than the specified time in milliseconds (number)

navigator.geolocation.clearWatch Like a timer - Stops watching for changes to the device's location referenced by the watchID parameter var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { enableHighAccuracy: true }); …. Later… navigator.geolocation.clearWatch(watchID);

Concerns Collection and use of geolocation data raises important privacy issues sensitive because it can reveal user's whereabouts if stored, the history of their travels app's privacy policy should discuss: how the app uses geolocation data whether it is shared with any other parties the level of precision of the data (for example, coarse, fine, ZIP code level) Should obtain the user's permission (e.g., by presenting choices for OK and No Thanks).

Google Maps

Google Maps Adding a Google Map to your app is very easy Use the coordinates from the geolocation object Must first obtain an API_KEY from google https://developers.google.com/maps/signup

Once you have your key ….4 Steps Load the Maps API JavaScript using a script tag. Declare the application as HTML5 using the <!DOCTYPE html> declaration. Create a div element named "map" to hold the Map. Define a JavaScript function that creates a map in the div.

1a. Referencing the Google API or Google Maps <script src=https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap async defer></script> URL contained in the script tag is the location of a JavaScript file that loads all of the symbols and definitions you need for using the Google Maps API async attribute (optional) lets the browser render the rest of your website while the Maps API loads When the API is ready, it will call the function specified using the callback parameter key parameter contains your application's API key https://developers.google.com/maps/documentation/javascript/get-api-key#key http://developers.google.com/maps/documentation/javascript/tutorial

2. HTML5 using the <. DOCTYPE html> 3 2. HTML5 using the <!DOCTYPE html> 3. div element named "map" to hold the Map <!DOCTYPE html> <div id="map"></div>

Define a JavaScript function that creates a map in the div var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 8 }); } </script>

Options Centering on latitude and longitude Zoom level, Zooming, Panning Markers MapType (Street, terrain, etc.)

Reference https://developers.google.com/maps/documentation/javas cript/reference#release-version