Firstly, I currently have the personal LC license with the iOS option and I am almost suspecting that not having the commercial license is to blame (or a bug in LC or my code somewhere). I've discovered that when you activate GPS with the iphoneStartTrackingLocation command, it takes a couple of seconds to lock onto your position (kind of expected, really). If you populate your variable from the iphoneCurrentLocation command too soon, your coordinates will end up being 0,0 because the key/value pair is not in existence yet. I'm trying to write some code that will wait until the current location has been received, and is not null or "0" before trying to do anything else. I've managed a small workaround while debugging, but it's not very good and has a nasty side effect. I've simply added "wait for 2 seconds" right after I start the location tracking, and before populating the results into a variable. However, no matter where I seem to put this code (stack, card, etc.) the "This was built with a Live Code Personal license, not for commercial distribution" splash screen just sticks around for an extra 2 seconds before going away. I've played with putting it in the preOpenStack, openStack, preOpenCard, openCard, etc. Every place I put this code, just makes the default LC splash screen just hang around longer. With this method, at least the variable I defined gets populated with legitimate GPS coordinates and I can get the Map to display with the correct location shown.
I really want to do my own splash screen (separate card) with a fake modal window (unless there is a way to do a real iOS-like modal popup, other than the "answer" dialog - I'm not seeing anything like that in MobGUI though) that says something like "Acquiring GPS Location" and runs a loop in the background continuously checking to see if tLocation["latitude"] is either NOT 0 or NOT null. Once I have populated the variable using "put iphoneCurrentLocation into tLocation", it's set with whatever iphoneCurrentLocation returns, even if it's nothing. I planned to work around that by performing the "put iphoneCurrentLocation into tLocation" command again in the loop.
The problem is, I can't seem to get the loop logic to work at all. When I do manage to get the loop to function, I get into an endless loop and my CPU spikes to 100%. It also never finds my location and leaves me trapped at the LC splash screen forever. I've tried it a multitude of different ways with no success. Sometimes I can't even get the loop code to function at all and the code just seems to never be evaluated, skipping my check/loop completely. I went back to basics and used some the EXACT code used in the LC dictionary, and couldn't even get that to work for me. A simple loop like below wouldn't work and this was literally copy/pasted from the dictionary. I never got an answer dialog at all.
Code: Select all
repeat with x = 1 to 5
answer x
end repeat
Can anyone offer any suggestions for how to get my loop that checks to see if tLocation["latitude"] has populated functioning correctly and avoid causing the LC splash screen from sticking around?
------------------------
Problems 2 & 3:
I wanted to play with live tracking of the current location. There is a default locationChanged command that I actually have working, but I have 2 related problems. First, it seems that locationChanged has no parameters that can be used, it just does its' own thing. In the current fashion, even in the simulator with a static destination sent, it's refreshing the location approximately once per second or so. I can't wrap my head around this at all. If I have the location coordinates hard set in the simulator (Apple HQ), shouldn't this locationChanged message only be seen when I manually change the location? It happens so fast, that it's hard to actually change the location in the simulator and get the map to update. It's almost like the browser is just refreshing on a 1 second interval. When I do change the location and get it in at the right time, however, the map does update correctly and show the new location before it starts refreshing over and over on that particular location. Any ideas?
Related to this, If I send new coordinates to the HTML page with the locationChanged message, the browser control refreshes. Is there a way to do this with AJAX or something, so you can't see the "page" change? Does anyone have any experience with this?
Last thing, I promise. Does anyone have any samples of dropping a pin on a Google Map within iOS and LC?