mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
one panel is user updates GPS other is automaic via pollling
This commit is contained in:
parent
4b6dc97880
commit
bcb7805006
@ -22,6 +22,17 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* At times we have to do polling in javascript, that is have function run at a specified interval
|
||||
* repeated times. However, certain function polling will reduce battery life thus
|
||||
* each of those features should have its own user defined interval
|
||||
* that our js reads in and uses with of course conservative value used
|
||||
* is consumer has not set one or the user of this library has not set one.
|
||||
*
|
||||
* Timeout only runs function twice not repeated times and thus we use
|
||||
* setInterval. This should correct problems with
|
||||
* both GPS and Accelerometer readings on Android
|
||||
*/
|
||||
|
||||
try {
|
||||
$ // Test if it is already used
|
||||
|
@ -16,9 +16,10 @@
|
||||
initGap = function() {
|
||||
// Device.init() initializes OS-Device values
|
||||
Device.init();
|
||||
// Device.Location.callback = updateLocation sets to funciotn updateLocation so that lat and lon can be passed
|
||||
Device.Location.callback = updateLocation;
|
||||
|
||||
|
||||
// Device.Location.init() to initalize location
|
||||
Device.Location.init();
|
||||
|
||||
//Device.Acceleration.callback = updateAccel;
|
||||
}
|
||||
@ -45,11 +46,17 @@ updateSettings = function() {
|
||||
}
|
||||
|
||||
updateLocation = function(lat, lon) {
|
||||
alert('lat=' + lat + ' lon=' + lon);
|
||||
// updateLocatin based on user input
|
||||
|
||||
|
||||
$('lat').value = lat;
|
||||
$('lon').value = lon;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
updateAccel = function(){
|
||||
$('accelx').value = accelX;
|
||||
$('accely').value = accelY;
|
||||
@ -70,7 +77,7 @@ addLoadEvent(initGap);
|
||||
|
||||
<ul id="home" title="Main" selected="true">
|
||||
<li><a href="#system" onclick="updateSettings();return false;">System...</a></li>
|
||||
<li><a href="#geo" onclick="Device.Location.init();">Geo-Location...</a></li>
|
||||
<li><a href="#geo" onclick="">Geo-Location...</a></li>
|
||||
<!-- <li><a href="#geo" onclick="updateLocation();">Geo-Location...</a></li> -->
|
||||
<li><a href="#accel" onclick="updateAccel();">Accelerometer...</a></li>
|
||||
<li><a href="#vibration" onclick="Device.vibrate();">Vibration</a></li>
|
||||
@ -115,24 +122,25 @@ addLoadEvent(initGap);
|
||||
</div>
|
||||
|
||||
<div id="geo" title="Geo Location" class="panel" >
|
||||
<form id="searchForm" action="POST">
|
||||
|
||||
<h2>Location</h2>
|
||||
<fieldset>
|
||||
<div class="row">
|
||||
<label>Lat</label>
|
||||
<input disabled="enabled" name="lat" id="lat" value="" type="text"></input>
|
||||
<input name="lat" id="lat" value="000.000" type="text"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Lon</label>
|
||||
<input disabled="enabled" name="lon" id="lon" value="" type="text"></input>
|
||||
<input name="lon" id="lon" value="000.000" type="text"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<a class="button blueButton" type="submit" onclick="updateLocation();">Update Location</a>
|
||||
<a class="button blueButton" type="submit" onclick="updateLocation(lat, lon);">Update Location</a>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="accel" title="Accelerometer" class="panel">
|
||||
|
||||
<h2>Accelerometer</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user