In this recipe, we'll use what we've learned about gauge charts and the HTML5 geolocation API to create a compass. Our compass may not be as accurate as a physical compass, but it should give us a decent approximation of our heading.
Note
Not all browsers/devices provide the necessary data to get heading information, so this recipe may not work in all circumstances.
To set up a basic page and install jQuery and Highcharts, refer to the instructions in the Getting ready section of the Creating your first chart recipe in Chapter 1, Getting Started with Highcharts.
To get started, follow the ensuing instructions:
Define the controls for our chart as shown in the following code:
<div id='container'></div> <button id='start-compass'>Start Compass</button> <script type='text/javascript'></script>
Define the options for our chart as shown in the following code:
$(document).ready(function() { var options = { chart...