- This topic has 24 replies, 3 voices, and was last updated 11 years, 4 months ago by SKnoxmn.
-
AuthorPosts
-
SKnoxmnMemberNew here, Looking for a “How to” example to capture geolocation data, post it to the screen and also to capture that same data for use in equations.
I’m seeing a lot of “on click” run javascripts that might be getting the data but so far none of the examples seem to address actually being able to view the data.
Appreciate any direction and guidance on this one.
SKnox
TurgutGuneysuMemberGreetings SKnoxmn,
Web page: http://www.genuitec.com/mobile/docs/usingMaps/usingMaps.html
3.4 CENTERING MAP ON YOUR CURRENT LOCATIONhas info on how to access GPS coordinates. Same page has good guidance on how to work with maps and GPS.
Also: http://docs.phonegap.com/en/2.2.0/cordova_geolocation_geolocation.md.html#geolocation.getCurrentPosition has info on the same functions from the API point of view.
Hope it helps.
TG
SKnoxmnMemberI do appreciate the quickness of the reply. I had been to that site already and I’m still missing the part about how we get that returned data into a field on the device.
My guess is that the script will run and pull that data but is not sure where to put it. So I’d think that a property of some kind on some field on the screen should be set to get that data.
Totally new to this, Flame on….
SKnox
Stu WadeMemberI asked the same question a couple of days ago.
The result was some sage advice and I was able to create a nice little test bed
the source is attached…
Edit: the link is iPad oriented, so will be severely truncated if you access on a phone
Attachments:
You must be logged in to view attached files.
SKnoxmnMemberAgain, I appreciate the time on this. Im not able to view the script on that one. Properties of the button are greyed out when I try to view it.
SKnox
Stu WadeMemberto view the button contents, click on the “…” to the right of the ‘greyed out’ text.
all it does is invoke a function call … all the actual code is in the testLocation_custom.js file to be found in the -www directory – i recommend using something like Notepad++ to view it – the view source features of the Test Centre are rather limited
SKnoxmnMemberStu, good call on the notepad++ suggestion.
I think what I’m looking for is an outline of the steps for getting lat / lon to display in a text field.
I have looked at the code you gave me, I made some changes to things like the name of the text field and such. But still not able to get anything to display on the phone.
This is why I’m thinking that Im missing some little, probably largely overlooked, piece of information in the actual process.
I have looked through the “example” section of the forums, there doesn’t seem to be any tutorials or youtube videos on how to do this.
I was unable to run your iPad testLocation on my iPhone, as stated before the whole thing being truncated and all….
So if anyone has a working version of an iPhone that I might be able to see it working, I’d like to se how it all functions put together. I’m looking for something simple that I can see each component.
I think this wil help me to better understand. and as always I do appreciate the help and the look at the code you have for the iPad.
SKnox
Stu WadeMemberSorry – by the time I’d finished playing with that thing it got pretty overcomplicated…
Torn out all the garbage and just left the basics
suitable for iPhone 4
Attachments:
You must be logged in to view attached files.
SKnoxmnMemberStu,
Exactly the kind of thing I was looking for. Very much appreciate you taking the time. Weird though, I ran this one and I was prompted for the app to use my current location and such, Im wondering if that was something that my previous attempts should have done as well.
Thank you again,
SKnox
Stu WadeMemberIf you deny access to current location – the geolocation call takes the onError path and in this example puts the error code (1) and the error message (user denied access) in the Lat and Long boxes.
The actual geolocation call is one of the most complex I have ever used with two functions as its parameters – no surprise that you found it rather arcane – I certainly did 🙂
Edit: with hindsight — JavaScript only supports call by value style parameters – so no parametric output allowed – the use of functions sort of provides a work around for this limitation.
SKnoxmnMemberGreat for a better understanding, for sure.
I did manage to get this going on my phone now so thats a good thing. Stand alone Location.mobi works well in both test on the PC as well as on the phone.
Problem now seems to be calling that location.mobi from my main.mobi.
I did set the onClick action to go to page Location.mobi but that doesn’t seem to work in either test or once published to the cloud.
Is something needed like loading all .js files in the Main.mobi? or does each page within the app get its own -www folder?
I guess this is more of a How does MobiOne handle projects as far as layout goes…
Anyone can chime in on this one, appreciate all the guidance.
SKnox
Stu WadeMemberAlthough there are work-arounds – the intent of M1 is to put all the eggs in one basket – the project.html file contains all the pages of the project and the project_custom.js file all the user provided code.
Simply copy all the user provided code from your _custom.js file for the stand alone .mobi into the main project_custom.js file. This assumes that the .mobi name remains the same when you combine the stand-alone into the full project.
Notes: do not copy the M1 provided routines at the top of the .js file – if you have any material in them you need to carefully move that material to the corresponding functions in the main .js file.
p.s. is it a US holiday today? seems very quiet…
SKnoxmnMemberSeems very quiet here too. (Best Buy Corp Headquarters) Seems like everyone took the day off for some reason.
I’ll go back and read your post again. Sounds like you’re saying take the main.mobi that has the button to load Location.mobi (stand alone works). Take the js from the “Get location” button and add that code to the main.mobi .js file?
by the way, once I add that in to the main.js file I can no longer get the test center to open for testing main.mobi
SKnox
Stu WadeMemberwhen the TC refuses to load this is normally an indication of gross errors in the _custom.js file.
are you sure you have not duplicated the system stubs or finished up with mismatched braces …?
notepad++ is your friend for the latter
SKnoxmnMemberI think I’ve got it now. Starting to make more sense.
SKnox -
AuthorPosts