Open the command-line tool, create a new PhoneGap project named
compass
, and add the platforms you want to target for this example.Add the Compass API plugin using the following command:
$ cordova plugin add cordova-plugin-device-orientation
Go to the
www
folder and open theindex.html
file. The threediv
tags are used to handle the compass arrows and the background:<section id="compass"> <div id="compassbg"></div> <div id="north"></div> <div id="arrow"></div> </section>
Go to the
css
folder, open theindex.css
file, and define the rules needed to have a separate background for each element of the compass:#compassbg { background-image: url(../img/Compass.png); } #north { background-image: url(../img/arrow_direction.png); } #arrow { background-image: url(../img/arrow_beta.png); } #compass, #arrow, #north, #compassbg { background-repeat: no-repeat...
PhoneGap Beginners Guide (third edition)
PhoneGap Beginners Guide (third edition)
Overview of this book
Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Introduction to PhoneGap
Building Your First PhoneGap Project
Mobile Frameworks
Working with Plugins
Using Device Storage and the Files API
Using the Contacts and Camera APIs
Accessing the Device Sensors and Locations API
Advanced PhoneGap
Getting Ready for Release
A Sample PhoneGap Project
The JavaScript Quick Cheat Sheet
Publishing Your App
Related Plugin Resources
PhoneGap Tools
Index
Customer Reviews