23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

return degrees + "°" + minutes + "\'" + seconds + "\"" + reference;<br />

To summarize, the sign of the value indicates direction. A positive value for latitude means North,<br />

negative means South; for longitude, positive means East, negative means West. The whole number<br />

portion of the value provides the degrees, and the fractional part contains the number of minutes<br />

expressed in base 60. Multiplying this value by 60 gives the whole minutes, with the remainder then<br />

containing the seconds. It’s odd, but that’s the kind of raw data you get from a GPS device that<br />

geolocation APIs normally convert for you directly.<br />

Media Properties in the Samples<br />

A few of the samples in the Windows SDK show you how to work with some of the properties described<br />

in the last section and how to work with those properties more generally. The Simple imaging sample, in<br />

Scenario 1 (js/scenario1.js), provides the most complete demonstration because you can choose an<br />

image file and it will load and display various properties, as shown in Figure 10-5 (I’ve scrolled down to<br />

see all the properties). I can verify that the date, camera make/model, and exposure information are all<br />

accurate.<br />

FIGURE 10-5 Image file properties in the Simple imaging sample.<br />

The sample’s openHandler method is what retrieves these properties from the file, specifically<br />

showing a call to StorageFile.properties.getImagePropertiesAsync and the use of<br />

ImageProperties.retrievePropertiesAsync for a couple of additional properties not already in<br />

ImageProperties. Then getImagePropertiesForDisplay coalesces these into a single object used by the<br />

sample’s UI. Some lines are omitted in the code shown here:<br />

439

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

Saved successfully!

Ooh no, something went wrong!