domenica 12 dicembre 2010

Implementing GeoLocation...

Another part of framework, this time the geoTools library.

Continue the development of the framework, and this time I reflected on the object "geolocation", which today is supported by all browsers, new generation, with some reservations, to be honest, at the Safari (PC version).
Despite the problem, the geolocation functions are very well, so why not incorporate a map for the visualization of geographic coordinates?
And so the framework decided to incorporate an open source library called OpenLayers. And this is the result!

// Fujon library reference
    var geo = fujon.geoTools ;
    // Create a map with OpenStreetMap
    var map = geo.easyMaps.createMap('myMap');
    // Set a loader widget
    var loader = new loadBox(map.element) ;
    loader.show() ;
    
    // callback function on success position obtained
    geo.successCallback.set(
        function(position){
            map.position = position ;
            //map.zoom = 5 ;
            loader.hide();
            map.show();
        }
    )
    // callback function on error
    geo.errorCallback.set(
        function(error){
            loader.hide();
            alert('error number : '+error.code);
        }
    )
    // Geo position request
    geo.requestPosition();

Nessun commento:

Posta un commento