{"id":3549,"date":"2012-05-21T15:57:00","date_gmt":"2012-05-21T15:57:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/antenna-aligner-part-2-finding-the-right-direction\/"},"modified":"2016-07-28T10:50:48","modified_gmt":"2016-07-28T10:50:48","slug":"antenna-aligner-part-2-finding-the-right-direction","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/antenna-aligner-part-2-finding-the-right-direction\/","title":{"rendered":"Antenna Aligner part 2: Finding the right direction"},"content":{"rendered":"<p>Last time I managed to get &#8220;my first app(tm)&#8221; built, published and running on my iPhone. This was really cool, a piece of my code running on my very own device. Ok, so I&#8217;m easily pleased!<a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/blogbits\/chris_george\/Finding-the-right-direction_DE76\/antenna-aligner-sketch_3.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/blogbits\/chris_george\/Finding-the-right-direction_DE76\/antenna-aligner-sketch_thumb_3.jpg\" width=\"244\" height=\"184\" class=\"float-right\" alt=\"antenna-aligner-sketch_thumb_3.jpg\" \/><\/a><\/p>\n<p>The next challenge was actually trying to determine what it was I wanted this app to do, and how to do it. Reverting back to good old paper and pen, I started sketching out designs for the app. I knew I wanted it to get a list of transmitters, then clicking on a transmitter would display a compass type view, with an arrow pointing the right way.<\/p>\n<p>I figured there would not be much point in continuing until I know I could do the graphical part of the project, i.e. the rotating compass, so armed with that reasoning (plus the fact I just wanted to get on and code!), I once again dived into visual studio. Using my friend (google) I found some example code for getting the compass data from the phone using the PhoneGap framework. <\/p>\n<p>\/\/ onSuccess: Get the current heading      <br \/>\/\/      <br \/>function onSuccess(heading) {      <br \/>   alert(&#8216;Heading: &#8216; + heading);      <br \/>}      <br \/>navigator.<a href=\"http:\/\/docs.phonegap.com\/en\/1.0.0\/phonegap_compass_compass.md.html#compass.getCurrentHeading\">compass.getCurrentHeading<\/a>(onSuccess, onError);<\/p>\n<p>Using the ripple mobile emulator this showed that it was successfully getting the compass heading. But it didn&#8217;t work when uploaded to my phone. It turns out that the examples I had been looking at were for PhoneGap 1.0, and Nomad uses PhoneGap 1.4.1. In 1.4.1, getCurrentHeading provides a compass object to onSuccess, not just a numeric value, so the code now looks like<\/p>\n<p>\/\/ onSuccess: Get the current magnetic heading     <br \/>\/\/      <br \/>function onSuccess(heading) {      <br \/>   alert(&#8216;Heading: &#8216; + heading.magneticHeading);      <br \/>};      <br \/>navigator.<a href=\"http:\/\/docs.phonegap.com\/en\/1.4.1\/phonegap_compass_compass.md.html#compass.getCurrentHeading\">compass.getCurrentHeading<\/a>(onSuccess, onError);     <\/p>\n<p>So the lesson learnt from this&#8230; read the documentation for the version you are actually using! This does, however, lead to compatibility problems with ripple as it only supports 1.0 which is a real pain. I hope that the ripple system is updated sometime soon.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time I managed to get &#8220;my first app(tm)&#8221; built, published and running on my iPhone. This was really cool, a piece of my code running on my very own device. Ok, so I&#8217;m easily pleased! The next challenge was actually trying to determine what it was I wanted this app to do, and how&#8230;&hellip;<\/p>\n","protected":false},"author":37746,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-3549","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/37746"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=3549"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3549\/revisions"}],"predecessor-version":[{"id":42158,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3549\/revisions\/42158"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=3549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=3549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=3549"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=3549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}