domingo, 16 de febrero de 2014

Finding your position with Geolocation

    The Geolocation API provides a method to locate the user’s exact (more or less – see below) position. This is useful in a number of ways ranging from providing a user with location specific information to providing route navigation.
    Although it’s not actually part of the HTML5 specification, as it was developed as a separate specification by the W3C, rather than theWHATWG, if the esteemed HTML5 Doctors Remy Sharp and Bruce Lawson felt it was fitting enough to include in their book, then it’s perfectly ok to write about it here.
    The API is actually remarkably simple to use and this article aims to introduce the API and show just how easy it is.



    Browser Compatibility

    Currently the W3C Geolocation API is supported by the following desktop browsers:
    • Firefox 3.5+
    • Chrome 5.0+
    • Safari 5.0+
    • Opera 10.60+
    • Internet Explorer 9.0+
    There is also support for the W3C Geolocation API on mobile devices:
    • Android 2.0+
    • iPhone 3.0+
    • Opera Mobile 10.1+
    • Symbian (S60 3rd & 5th generation)
    • Blackberry OS 6
    • Maemo

    Data Protection

    The specification explicitly states that since the nature of the API also exposes the user’s location and therefore could compromise their privacy, the user’s permission to attempt to obtain the geolocation information must be sought before proceeding. The browser will take care of this, and a message will either appear as a popup box, or at the top of the browser (implementation is browser specific) requesting the user’s permission.

    Safari asking the user for permission to obtain their Geolocation information

    Geolocation sources

    A number of different sources are used to attempt to obtain the user’s location, and each has their own varying degree of accuracy. A desktop browser is likely to use WiFi (accurate to 20m) or IP Geolocation which is only accurate to the city level and can provide false positives. Mobile devices tend to use triangulation techniques such as GPS (accurate to 10m and only works outside), WiFi and GSM/CDMA cell IDs (accurate to 1000m).

    Using the API

    Before you actually attempt to use the Geolocation API, you first need to check if the browser actually supports it. The API usefully provides a function for this which can be called as follows:
    if (navigator.geolocation) {
      // do fancy stuff
    }
    Obviously if this returns false, you should optionally inform the user of the inferiority of their browser and laugh in their face (not really).
    Through the API, there are two functions available to obtain a user’s location:

    getCurrentPosition and watchPosition

    Both of these methods return immediately, and then asynchronously attempt to obtain the current location. They take the same number of arguments, two of which are optional:
    1. successCallback – called if the method returns successfully
    2. [errorCallback] – called if the method returns with an error
    3. [options] – a number of options are available:
    • enableHighAccuracy – provides a hint that the application would like the best possible results. This may cause a slower response time and in the case of a mobile device, greater power consumption as it may use GPS. Boolean with a default setting of false.
    • timeout – indicates the maximum length of time to wait for a response. In milliseconds with a default of 0 – infinite.
    • maximumAge – denotes the maximum age of a cached position that the application will be willing to accept. In milliseconds, with a default value of 0, which means that an attempt must be made to obtain a new position object immediately.
    Before mentioning the differences between the two, another method needs to be introduced:

    clearWatch

    This method takes one argument, the watchID of the watch process to clear (which is returned by watchPosition)
    Now, the main difference between getCurrentPosition andwatchPosition is that watchPosition keeps informing your code should the position change, so basically it keeps updating the user’s position. This is very useful if they’re on the move and you want to keep track of their position, whereas getCurrentPosition is a once off. This method also returns a watchID which is required when you want to stop the position constantly being updated by callingclearWatch method is called.
    When the user’s position is returned, it is contained within a Positionobject which contains a number of properties:

    PropertyDetails
    coords.latitudeDecimal degrees of the latitude
    coords.longitudeDecimal degress of the longitude
    coords.altitudeHeight in metres of the position above thereference ellipsoid
    coords.accuracyThe accuracy in metres of the returned result. The value of this setting informs the application how useful the returned latitude/longitude value actually is. This can help in determining if the returned result is accurate enough for the purpose it is intended for, e.g. values for streetview locations will need to be more accurate than those for a country based location
    coords.altitudeAccuracyThe accuracy in metres of the returned altitude
    coords.headingDirection of travel of the hosting device, clockwise from true north
    coords.speedThe current ground speed of the hosting device in metres per second
    timestampTimestamp of when the position was acquired
    Amongst these only which is coords.latitudecoords.longitudeand coords.accuracy are guaranteed to be returned (all others may be null), and the first two are by and large the most relevant, as it is from these that a position can be plotted on a Google Map, for example.
    You can read more about the Position object and the coordinates interface on the W3 specification itself.


    Putting it all together

    Putting this altogether, the following code will attempt to obtain a user’s location, calling the method displayPosition on success which simply pops up an alert box with the captured latitude and longitude:
    if (navigator.geolocation) {
      var timeoutVal = 10 * 1000 * 1000;
      navigator.geolocation.getCurrentPosition(
        displayPosition,
        displayError,
        { enableHighAccuracy: true, timeout: timeoutVal,maximumAge: 0 }
      );
    }
    else {
      alert("Geolocation is not supported by this browser");
    }
    function displayPosition(position) {
      alert("Latitude: " + position.coords.latitude + ", Longitude: " + position.coords.longitude);
    }
    The code above also calls the displayError method when attempt to fetch the user’s location data. This function simple converts the returned error code to an appropriate message:
    function displayError(error) {
      var errors = {
        1: 'Permission denied',
        2: 'Position unavailable',
        3: 'Request timeout'
      };
      alert("Error: " + errors[error.code]);
    }

    A final word

    This is just a simple introduction to using the Geolocation API and one of it’s uses.
    Of course the API can be used for more than simply plotting a position on a map (although that in itself is quite useful). The specification itself offers a list of potential use cases for the API such as:
    • Finding and plotting points of interest in the user’s area
    • Annotating content with location informationShowing a user’s position on a map (helping with directions of course!)
    • Turn-by-turn route navigation – using watchPosition
    • Up-to-date local information – updates as you move

    Examples

    To see geolocation in action, I’ve put together a couple of quick examples in which I encourage you to view source and then go and try it out for yourself.

    Based on the work Ian Devlin

    jueves, 22 de septiembre de 2011

    Desarrollo de aplicaciones con el API foursquare

    Ya lo sé tenia mucho tiempo sin actualizar mi blog pero ahí les va.


    Muchas personas que trabajan los mapas quieren interactuar con foursqare muy lógico  esta red social, tiene mucha de la inteligencia colectiva de las personas que comparten sus intereses y check-in con sus amigos. 


    Hoy trataré de aportar algunas cosas en nuestra lengua, ya que la mayoría de los sitios como saben están en ingles.


    Vamos a jugar con la API de foursqare para demostrar el potencial de la API de desarrollador.


    Explorar Lugares recomendados y populares.

    https://api.foursquare.com/v2/venues/explore
    Devuelve una lista de lugares recomendados cerca de la ubicación actual.

    Si se autentican, el método potencialmente personaliza la clasificación basada entre ti y tus amigos. Si no se autentican,no conseguirás esta personalización.

    Este es un API experimental. Estoy muy contentos de compartir, pero es una característica muy nueva la cual está en proceso de cambio, y también yo estoy  todavía aprendiendo, si este es tu caso. Por favor, dame una notificación
     y proporcionar información mas detallada por correo si tienes problemas.


    Endpoint forma parte de la API lugares.



    He aquí una guía paso a paso sobre cómo hemos construido la muestra lugares recomendados. Siéntase libre de utilizar el código e ideas estos mismos están basados en la ayuda de foursqare. Este ejemplo se utiliza el flujo de JavaScript OAuth.

    1 El primer paso es el registro de un manejador  OAuth Consumers. Vaya a la página Administrar OAuth Consumidores y haga clic en el botón Registrar un nuevo Consumer. Rellene el nombre de la aplicación, la aplicación web, y los campos de devolución de llamada URL. La dirección URL de devolución de llamada es la URL que el usuario será devuelto a después de autorizar su aplicación en el cuadrado. En este caso, tanto el sitio web de aplicaciones y la URL de devolución de llamada son:

    https://developer.foursquare.com/docs/samples/explore.html


    El registro de un consumer le dará las credenciales de API. El ID de cliente y el secreto del cliente son únicos para su consumo. Asegúrese de mantener en secreto su cliente, uh, es un !secreto¡.

    2 Vamos a empezar con algo de código básico. Todo lo que hemos hecho es crear la estructura HTML de la página. Para este ejemplo, voy a usar jQuery, jQuery bbq, y la API de Google Maps.








    3 El siguiente paso es la autenticación del usuario. Los lugares / explore endpoint no requieren un usuario autentificado, pero si la solicitud se presente en nombre de un usuario de foursqare,  las recomendaciones serán personalizadas para el usuario (segun los chekins de sus amigos). Estoy usando JQuery BBQ para analizar la dirección del token de acceso, pero se puede omitir esta biblioteca y analizar:

    4 Ahora que tenemos un token acceso para el usuario, que vamos a utilizar para la API de geolocalización HTML5 para determinarla ubicación del usuario. Estamos entonces vamos a crear un mapa mediante el API de Google Maps que se centra en la ubicación del usuario.


    5 El último paso es la consulta de la API en cuadro para los lugares recomendados y la colocación de un marcador en el mapa de cada lugar. Los lugares / explore punto final responde a las peticiones GET para poder fijar los parámetros de la URL. En este caso, estamos enviando al usuario de latitud y longitud a través del parámetro ll. Usted debe incluir el token de acceso al haceruna solicitud autenticada.


    Ahora el resultado Aquí 

    lunes, 26 de octubre de 2009

    Respalda Google Docs metelo en un Zip y descárgalo

     

    Desde que inició el servicio de Google Docs he sido un asiduo participante pero con lo paranoico que soy siempre he optado por tener un respaldo de mis documentos en caso de que inicie la tercera guerra mundial me gustaría tener una copia en al menos un USB. Google a iniciado un proyecto desde septiembre para liberar los datos personales de nosotros sus esclavos ( + detalles aquí ) producto de esto se libera por parte de Google una nueva funcionalidad en Docs (Convert,Zip & Download)

    image

    Puedes ver más detalles sobre esta funcionalidad en el mismo blog del equipo de Google Docs. Recuerda puedes bajar uno,varios o todos tus archivos(y así prepararte para el holocausto nuclear).

    Esta funcionalidad será replicada a los productos de Google que mantengan datos personales (gmail,contacts) entre muchos otros.

    Visita el sitio del grupo de ingenieros que trabajan en este proyecto de Google en http://dataliberation.org o si te interesa este tipo de funciones siguelos en Twitter @dataliberation y de paso me das follow  @chessco

    Bueno espero les sirva de algo..tienes dudas estoy a tus ordenes.. para ampliarte cualquier duda!

    Desde Ciudad Obregón Sonora,México (Valle del Yaqui)

    Saludos Terrícolas.

    domingo, 3 de mayo de 2009

    Nuestro nuevo sitio


    En obregon
    Periodicos,empleos y
    mapas.-¡Informate ahora!-
    www.enobregon.com


    sábado, 18 de abril de 2009

    Mapas de Ciudad Obregón/ Maps Ciudad Obregon


    Uno de los grandes éxitos del internet de nuestros días es la puesta en marcha de los mapas, a quien no nos dejaron en la primaria un mapa en nuestra clase de Geografía. En Ciudad Obregón,Sonora, hay un grupo creciente de personas que checan sus mapas vía internet, cada día se ven mas aplicaciones y personas que traen sus propios equipos GPS así que en el futuro veremos un uso intensivo en esta nueva región tecnológica del Yaqui Valley. Yo les prometo que pronto les traeré nuevas aplicaciones de mapas para su beneficio; así que háganme llegar sus comentarios y necesidades. ¿Y a ti te gustan los mapas?
    webmaster arroba cdobregon punto net
    One of the great successes of the internet today is the launch of the maps, unless he left us a map in the Elementary in our geography class. In Ciudad Obregon, Sonora, there is a growing group of people to check their maps via the Internet, every day more applications and are persons who bring their own GPS equipment so that in future we will see heavy use in this new technological Yaqui Valley region . I promise I will soon bring new applications of maps for your benefit, so let me get your feedback and needs. And you like maps?
    webmaster at cdobregon dot net

    [Nuevo] Mapa delictivo de cajeme



    Asignar imagen

    map-c4e7a98576c3


    mapa1
        
    Asignar imagen
    Virtual Earth Cd Obregon

    Ver Comida Cd. Obregon en un mapa más grande
    Lugares para comer en Google Maps
    [Nuevo]Mapa delictivo Cd Obregon
    Ciudad Obregón es la cabecera del municipio de Cajeme y una de las principales poblaciones del Estado de Sonora(México). Es una ciudad cuya principal actividad económica ha sido la agricultura, la cual, se realiza extensivamente en elValle del Yaqui que está situado al sur de la ciudad, contando con uno de los sistemas de riego más importantes del país.
    Ciudad Obregón,Sonora;México en Wikipedia
    Ciudad Obregón (locally known as Obregón) is the second largest city in the northern Mexican state of Sonora and is situated 525 km south of the state's border with the U.S. state of Arizona at 27°29′38″N 109°56′20″W. It is also the municipal seat of Cajeme municipality, located in the Yaqui Valley.
    Ciudad Obregón at Wikipedia.

    sábado, 14 de marzo de 2009

    Hotmail ya puede ser incluido en cualquier lector de correo

    ¿ SABIAS QUE PUEDES INCLUIR YA TU HOTMAIL EN TU LECTOR DE CORREO FAVORITO Y TAMBIÉN AGREGARLO COMO CUENTA DE CORREO POP3 EN TU GMAIL?

    Anteriormente se tenia que pagar en tu cuenta plus de hotmail por tener el servicio de tu correo en un solo lugar esto es muy practico para las personas que tenemos varios correos el del trabajo, el de messenger y algunos otros varios mas como los dominios que administro. Yo particularmente fui olvidando mi cuenta de hotmail y use mas la de mi dominio, pero aun así muchas personas y socios de negocio me seguían escribiendo a mi cuenta de hotmail. Por esto es muy buena noticia que el día de hoy pueda acceder a este servicio desde mi cuenta de dominio bajo Google App. Así que me complace anunciarles que Microsoft libera el acceso POP3 a Hotmailen todo el mundo, poniendo fin a los años en que mi dirección estaba atrapada en hotmail

    Configurarlo es bastante simple en la mayoría de las aplicaciones de correo electrónico-acaba de crear una nueva cuenta con los siguientes datos del equipo de Windows Live:

    Servidor POP: pop3.live.com (puerto 995)
    POP requiere SSL?
    Nombre de usuario: su identificador de Windows Live ID, por ejemplo yourname@hotmail.com
    Contraseña: La contraseña que habitualmente utiliza para acceder a Hotmail o Windows Live
    Servidor SMTP: smtp.live.com (Puerto 25)
    Se requiere autenticación? Sí (esto coincide con su nombre de usuario y contraseña POP)
    TLS / SSL requiere?

    Yo se que la mayoría de mis amigos geek utilizan Gmail ha POP3, así que ya saben cárguenlo dentro de su gmail y tengan su correo unificado. Yo ya lo tengo funcionando!

    Tienes dudas no te detengas en preguntar yo te puedo ayudar con esto..estamos en contacto.

    Saludos Terrícolas.

    Francisco