25.02.2013 Views

Peter Lubbers - Pro HTML 5 Programming

Pro HTML 5 Programming

Pro HTML 5 Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

94<br />

CHAPTER 4 ■ USING THE <strong>HTML</strong>5 GEOLOCATION API<br />

Figure 4-2. The notification bar is triggered in Firefox when the <strong>HTML</strong>5 Geolocation APIs are used<br />

The mechanism is triggered when the <strong>HTML</strong>5 Geolocation code is executed. Simply adding <strong>HTML</strong>5<br />

Geolocation code that is not called anywhere (as, for example, in an onload method) does not do<br />

anything. If, however, the <strong>HTML</strong>5 Geolocation code is executed, for example, in a call to<br />

navigator.geolocation.getCurrentPosition (explained in more detail later on), the user is prompted to<br />

share their location with the application. Figure 4-3 shows what happens on Safari, running on an<br />

iPhone.<br />

Figure 4-3. The notification dialog box is triggered in Safari when the <strong>HTML</strong>5 Geolocation APIs are used<br />

Apart from providing the necessary mechanism to request permission to share your location, some<br />

implementations (Firefox, for example) also allow you to remember the permission granted to the site<br />

for the next time you enter. This is similar to how you can remember passwords for certain sites in your<br />

browser.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!