Previewing two HTML5 features for use in EGL applications
Scott_Greer 270001WB8W Visits (2653)
Geolocation: Your place in the world
We've all gotten acquainted -- and even dependent on -- satellite-based navigation using GPS (Global Positioning System), and GPS receivers are so commonplace they're often found in modern smartphones, tablets and other devices. Although GPS satellites are remarkable engineering feats, the GPS system succeeds on a relatively simple premise: your real-time geographical coordinates enable a wide array of services and features from navigation to geo-tagging to location-based services.
But GPS isn't the only way to figure out where you are. Whereas GPS involves triangulating your position with respect to satellites in space, it's also possible to do similar triangulation of your position with respect to nearby cell towers. This is how some phones can approximate your position even in the absence of GPS hardware (or service). Similar techniques can approximate your position using your WiFi connection or your IP address -- there are any number of approaches with varying degrees of accuracy and various pros and cons.
Fortunately, none of these technical details are actually relevant to adding location awareness to your Rich Internet Application. HTML5's geolocation support provides a simple API that allows you to obtain the current position or monitor it for updates, without regard to how the position is being determined. It's up to the browser to figure out how to obtain location information given the device's capabilities and come up with the coordinates for use in your application. We've "wrappered" this API with an EGL library, which means that your EGL applications have access to the device's geographical coordinates, subject to the user's permission. Keep in mind that it's ultimately up to the user to grant consent for their location information to be accessed. Of course, how this permission is obtained can vary by browser; it may involve some combination of on-screen prompts and browser configuration options.
The preview includes a sample EGL application that illustrates the use of geolocation in conjunction with mapping.
I should mention that while developing this preview of geolocation support, we did encounter some problems with browsers that should've been able to give us our position and yet failed to do so. As always, you should make sure you understand -- and then test -- your target platforms because results may vary across the various combinations of browsers and operating systems.
Web storage: Client-side data
The purpose of Web storage is simple: to provide Rich Internet Applications with a browser-based, client-side storage mechanism, and to do it in a simple, standardized way.
The WebStorage API is based on a simple model for storing key/value pairs and consists of two variants: Local storage and Session Storage. Local storage provides persistent storage that is maintained even if the browser itself is closed. If you're familiar with HTTP cookies, local storage is similar but differs in two important ways. First, local storage is entirely browser-based and doesn't involve any data being transmitted to the server (whereas cookies are transmitted on every request), and second, local storage offers much more capacity -- typically up to 5 megabytes or more depending on the browser's implementation. Session storage is just like local storage except that its data is associated with a single browser window and its contents are lost as soon as that browser window is closed. With this, session storage is particularly useful for those cases in which a user might have multiple windows open at the same time; each effectively will have its own sandbox in which to store temporary data.
The preview includes a sample application that allows you to simultaneously explore local storage and session storage; with access to both at the same time with the sample's straightforward user interface, you can explore how these variants of Web Storage work and how they differ.
If there's a basic premise behind the power of EGL Rich UI, it's this: technology is a means to an end. HTML5 is a technology that offers RIAs some important new capabilities that begin to eliminate the last of the functional gaps between RIAs and their desktop ancestors. So rather than get lost in the noise about what HTML5 is or isn't, take a look at this preview and start to think about how the HTML5 features offered herein can benefit your applications.
Of course, there's much more to HTML5 than these first two features we're covering now, so look for future updates as we add other ways that HTML5 can enhance your EGL applications.
Ready to get started?