HTML5 Geolocalizacion
Upcoming SlideShare
Loading in...5
×
 

HTML5 Geolocalizacion

on

  • 5,062 views

 

Statistics

Views

Total Views
5,062
Views on SlideShare
1,381
Embed Views
3,681

Actions

Likes
1
Downloads
24
Comments
0

2 Embeds 3,681

http://shockbyte.net 3680
http://inoreader.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • The following steps are shown in the diagram: A user navigates to a location-aware application in the browser.The application web page loads and requests coordinates from the browser by making a Geolocation function call. The browser intercepts this and requests user permission. Let's assume that the permission is granted.The browser retrieves coordinate information from the device it is running on. For example, the IP address, Wi-Fi, or GPS coordinates. This is an internal function of the browser.The browser sends these coordinates to a trusted external location service, which returns a detailed location that can now be sent back to the host of the HTML5 Geolocation application.
  • The successCallback function parameter tells the browser which function you want called when the location data is made available. This is important because operations such as fetching location data may take a long time to complete. No user wants the browser to be locked up while the location is retrieved, and no developer wants his program to pause indefinitely—especially because fetching the location data will often be waiting on a user to grant permission. The successCallback is where you will receive the actual location information and act on it.However, as in most programming scenarios, it is good to plan for failure cases. It is quite possible that the request for location information may not complete for reasons beyond your control, and for those cases you will want to provide an errorCallback function that can present the user with an explanation, or perhaps make an attempt to try again. While optional, it is recommended that you provide one.Finally, an options object can be provided to the HTML5 Geolocation service to fine-tune the way it gathers data. This is an optional parameter that we will examine later.

HTML5 Geolocalizacion HTML5 Geolocalizacion Presentation Transcript

  • HTML5 Geolocalizacion Rodolfo Finochietti
  • HTML5 Geolocalizacion
  • Geolocalizacion• Permite a los usuarios compartir su ubicación• Muestra la posición de un usuario en el mapa• Util para Tagging de contenido (fotos/videos)• Navegación Turn-by-turn• Alertar de puntos de interés• Social networking View slide
  • Demo View slide
  • Arquitectura
  • Informacion de localizacionLa informacion de localizacion consisteen coordendas de latitud y longitud, einformacion de presicion
  • Informacion de localizacion• Dependiendo del dispositivo, metadata adicional puede ser provista: • Altitud • Velocidad• Si no hay informacion adicional se recibe a null
  • Fuentes de informacion de localizacion• Un dispositivo puede usar alguna de las siguientes fuentes: • IP Address • Coordinate triangulation • Global Positioning System (GPS) • Wi-Fi with MAC addresses from RFID, Wi-Fi, and Bluetooth • GSM or CDMA cell phone IDs • User defined
  • Privacidad
  • Usando la API de Geolocalizacion Copyright © 2010, Kaazing Corporation,. All rights reserved.
  • JavaScript //Checking for browser support: if(navigator.geolocation) { document.getElementById("support").innerHTML = "HTML5 Geolocation is supported."; } else { document.getElementById("support").innerHTML = "HTML5 Geolocation is not supported."; }
  • Tipos• Hay dos tipos: 1. Por unica vez (getCurrentPosition) 2. Actualizacion de la posicion (watchPosition)
  • JavaScript //One shot request void getCurrentPosition( in PositionCallback successCallback, in optional PositionErrorCallback errorCallback, in optional PositionOptions options); //Access user’s position navigator.geolocation.getCurrentPosition( updateLocation, handleLocationError);
  • JavaScript //Update the UI function updateLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; var accuracy = position.coords.accuracy; document.getElementById("latitude").innerHTML = latitude; document.getElementById("longitude").innerHTML = longitude; document.getElementById(“accuracy”).innerHTML = “This location is accurate within “ + accuracy + “ meters.” }
  • Codigos de error• UNKNOWN_ERROR (code 0)• PERMISSION_DENIED (code 1)• POSITION_UNAVAILABLE (code 2)• TIMEOUT (code 3) Copyright © 2010, Kaazing Corporation,. All rights reserved.
  • JavaScript //Repeated position updates var watchId = navigator.geolocation.watchPosition( updateLocation, handleLocationError); // do something with the location updates! // ... // Stop receiving location updates navigator.geolocation.clearWatch(watchId); Copyright © 2010, Kaazing Corporation,. All rights reserved.
  • Integración de con Google Maps• Las coordenadas no son fáciles de descifrar sin verlas en un mapa• Google Maps tiene soporte para HTML5 Geolocation
  • JavaScript //Show coordinates on a Google Map // Create a Google Map //See Google API for more detail var map = new google.maps.Map2(document.getElementById("map")); function updateLocation(position) { //pass the position to the Google Map and center it map.setCenter(new google.maps.LatLng( position.coords.latitude, position.coords.longitude, 13); // zoom level } navigator.geolocation.getCurrentPosition( updateLocation, handleLocationError);
  • Browser Support• Firefox 3.5• Safari 5.0• Chrome 5.0• Opera 10.6• IE 9+
  • ¿Preguntas?
  • rodolfof@lagash.comhttp://twitter.com/rodolfof http://shockbyte.net ¡GRACIAS!