- This topic has 4 replies, 2 voices, and was last updated 11 years, 4 months ago by SKnoxmn.
-
AuthorPosts
-
SKnoxmnMemberTrying to capture the “heading” and angle on my iphone. Having some trouble getting it to post the data to the device.
Stu (UK Stu) has been most helpful in getting me started with training on the function calls, successes fails and errors, very much appreciated.
I have been to the phone gap page and seen the examples.
function getCurrentHeading()
{
navigator.compass.getCurrentHeading(compassSuccess, compassError);
}function compassSuccess(heading) // function name MUST match that given above
{
$(‘#m1-Location-textField4’).val(heading);
}function compassError()
{
}// any error action you might likeand my “on click” function: return getCurrentHeading():
Any suggestions are appreciated, or resources listing what functions are like: getting angle the device is held at.
SKnoxp.s. I figured I’d start a new topic since my previous question was more than answered.
support-michaelKeymasterHere is a simple compass app I posted today that uses compass.watchHeading(): http://www.genuitec.com/support-genuitec/viewtopic.php?f=14&t=6009
To access the device orientation in space see this article:
http://www.html5rocks.com/en/tutorials/device/orientation/What device/os are you developing for?
SKnoxmnMemberI’m looking at iPhone right now. Being I have the 4s figured best to start with that.
I checked out the HTML5Rocks site. that one seems to function fine on my phone. It does things that I dont need it to do, but as far as a working example it shows that it can work.
What I’m trying to get working is a “snapshot” of the current location lat/lon/altitude, direction the device is pointing based on true north (versus magnetic) and the angle up or down that it is pointing.
I figure its going to have to run for a few seconds to land on a best guess for lat / lon. But looking to just set the phone and click a button. Capture that data to be used elsewhere.
Credit to Stu Wade; Some of his examples and guidance have helped me to get to the point of capturing the lat/lon and altitude. So I have learned a lot about this from him. I’m hoping to get a better understanding ot how MobiOne works along the way.
Example: I didn’t create any html doc… it was created somewhere along the line. I didn’t create Start.js that was also created along the way once I saved my project. I’m not sure that once it is created if I can edit the start.js and add additional variables for the additional buttons and boxes that are added to the project.
or if that is updated from the custom_js files that get added based on additional screens.Ok now Im rambling….
SKnox
support-michaelKeymasterHere is another article (google for even more) with code examples that illustrates accessing device orientation: http://mobiforge.com/developing/story/html5-mobile-web-device-orientation-events
You can easily incorporate this sensor access from your <project>_custom.js or any javascript file that you add to the project via the JavaScript libraries property on any .mobi file in your project. I hope this helps.
SKnoxmnMember@support-wayne wrote:
Here is another article (google for even more) with code examples that illustrates accessing device orientation: http://mobiforge.com/developing/story/html5-mobile-web-device-orientation-events
You can easily incorporate this sensor access from your <project>_custom.js or any javascript file that you add to the project via the JavaScript libraries property on any .mobi file in your project. I hope this helps.
I’m going to head for home and read over a pile of those links on the MobiForge site. Looks like a lot of good info there of things that I probably should become familiar with.
I hear people saying its easy to incorporate additional scripts and sensors into my _custom.js The part I’ll try to learn here is how to accomplish that.
Seems that some of the things for additional functions needs to be defined the project.js or for web apps these things need to be defined in the project.html
I’ll go do some reading up….
SKnox
-
AuthorPosts