School of Computing Science and Engineering
Course Code : CSDA4070 Course Name: Data Visualization
Name of the Faculty: Mr.S.Rakesh kumar Program Name: B.Tech.(CS)
HTML5 - Geolocation
Software process and Process Models
HTML5 Geolocation API lets you share your location with your
favorite web sites. A JavaScript can capture your latitude and
longitude and can be sent to backend web server and do fancy
location-aware things like finding local businesses or showing
your location on a map.
Today most of the browsers and mobile devices support
Geolocation API. The geolocation APIs work with a new
property of the global navigator object ie. Geolocation object
which can be created as follows −
2
HTML5 - Geolocation
Program Name: B.Tech.(CS)
Software process and Process Models
The geolocation object provides the following methods −
Method & Description
1getCurrentPosition()This method retrieves the current
geographic location of the user.
2watchPosition()This method retrieves periodic updates about
the current geographic location of the device.
3clearWatch()This method cancels an ongoing watchPosition
call.
3
Geolocation Methods
Program Name: B.Tech.(CS)
Software process and Process Models
Example
Following is a sample code to use any of the above method −
4
Geolocation Methods
Program Name: B.Tech.(CS)
Software process and Process Models
Geolocation methods getCurrentPosition() and
getPositionUsingMethodName() specify the callback method
that retrieves the location information. These methods are
called asynchronously with an object Position which stores the
complete location information.
The Position object specifies the current geographic location of
the device. The location is expressed as a set of geographic
coordinates together with information about heading and speed.
The following table describes the properties of the Position
object. For the optional properties if the system cannot provide
a value, the value of the property is set to null.
5
Location Properties
Program Name: B.Tech.(CS)
Software process and Process Models
6
Location Properties
Program Name: B.Tech.(CS)
Software process and Process Models
7
Location Properties
Program Name: B.Tech.(CS)
Software process and Process Models
8
Location Properties
Program Name: B.Tech.(CS)
Example
Following is a sample code which makes use of Position
object. Here showLocation method is a callback method −
Software process and Process Models
9
Handling Errors
Program Name: B.Tech.(CS)
Geolocation is complicated, and it is very much required to
catch any error and handle it gracefully.
The geolocations methods getCurrentPosition() and
watchPosition() make use of an error handler callback
method which gives PositionError object.
This object has following two properties −
Software process and Process Models
1
Handling Errors
Program Name: B.Tech.(CS)
The following table describes the possible error codes
returned in the PositionError object.
Software process and Process Models
1
Handling Errors
Program Name: B.Tech.(CS)
Example
Following is a sample code which makes use of
PositionError object. Here errorHandler method is a callback
method −
Software process and Process Models
1
Position Options
Program Name: B.Tech.(CS)
Following is the actual syntax of getCurrentPosition()
method −
Software process and Process Models
1
Position Options
Program Name: B.Tech.(CS)
Here third argument is the PositionOptions object which
specifies a set of options for retrieving the geographic
location of the device.
Following are the options which can be specified as third
argument −
Software process and Process Models
1
Position Options
Program Name: B.Tech.(CS)
Software process and Process Models
1
Position Options
Program Name: B.Tech.(CS)
Example
Following is a sample code which shows how to use above
mentioned methods −
16
References:
Websites
– https://haralick.org/DV/Handbook_of_Data_Visualization.pdf
– https://www.tutorialspoint.com/html5/html5_canvas.htm
– https://www.tutorialspoint.com/html5/html5_geolocation.htm
Program Name: B.Tech.(CS)
HTML5 - Geolocation.pptxkmkjvjrg4tnjijii

HTML5 - Geolocation.pptxkmkjvjrg4tnjijii

  • 1.
    School of ComputingScience and Engineering Course Code : CSDA4070 Course Name: Data Visualization Name of the Faculty: Mr.S.Rakesh kumar Program Name: B.Tech.(CS) HTML5 - Geolocation
  • 2.
    Software process andProcess Models HTML5 Geolocation API lets you share your location with your favorite web sites. A JavaScript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map. Today most of the browsers and mobile devices support Geolocation API. The geolocation APIs work with a new property of the global navigator object ie. Geolocation object which can be created as follows − 2 HTML5 - Geolocation Program Name: B.Tech.(CS)
  • 3.
    Software process andProcess Models The geolocation object provides the following methods − Method & Description 1getCurrentPosition()This method retrieves the current geographic location of the user. 2watchPosition()This method retrieves periodic updates about the current geographic location of the device. 3clearWatch()This method cancels an ongoing watchPosition call. 3 Geolocation Methods Program Name: B.Tech.(CS)
  • 4.
    Software process andProcess Models Example Following is a sample code to use any of the above method − 4 Geolocation Methods Program Name: B.Tech.(CS)
  • 5.
    Software process andProcess Models Geolocation methods getCurrentPosition() and getPositionUsingMethodName() specify the callback method that retrieves the location information. These methods are called asynchronously with an object Position which stores the complete location information. The Position object specifies the current geographic location of the device. The location is expressed as a set of geographic coordinates together with information about heading and speed. The following table describes the properties of the Position object. For the optional properties if the system cannot provide a value, the value of the property is set to null. 5 Location Properties Program Name: B.Tech.(CS)
  • 6.
    Software process andProcess Models 6 Location Properties Program Name: B.Tech.(CS)
  • 7.
    Software process andProcess Models 7 Location Properties Program Name: B.Tech.(CS)
  • 8.
    Software process andProcess Models 8 Location Properties Program Name: B.Tech.(CS) Example Following is a sample code which makes use of Position object. Here showLocation method is a callback method −
  • 9.
    Software process andProcess Models 9 Handling Errors Program Name: B.Tech.(CS) Geolocation is complicated, and it is very much required to catch any error and handle it gracefully. The geolocations methods getCurrentPosition() and watchPosition() make use of an error handler callback method which gives PositionError object. This object has following two properties −
  • 10.
    Software process andProcess Models 1 Handling Errors Program Name: B.Tech.(CS) The following table describes the possible error codes returned in the PositionError object.
  • 11.
    Software process andProcess Models 1 Handling Errors Program Name: B.Tech.(CS) Example Following is a sample code which makes use of PositionError object. Here errorHandler method is a callback method −
  • 12.
    Software process andProcess Models 1 Position Options Program Name: B.Tech.(CS) Following is the actual syntax of getCurrentPosition() method −
  • 13.
    Software process andProcess Models 1 Position Options Program Name: B.Tech.(CS) Here third argument is the PositionOptions object which specifies a set of options for retrieving the geographic location of the device. Following are the options which can be specified as third argument −
  • 14.
    Software process andProcess Models 1 Position Options Program Name: B.Tech.(CS)
  • 15.
    Software process andProcess Models 1 Position Options Program Name: B.Tech.(CS) Example Following is a sample code which shows how to use above mentioned methods −
  • 16.