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.
|
* 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 {
|
try {
|
||||||
$ // Test if it is already used
|
$ // Test if it is already used
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
initGap = function() {
|
initGap = function() {
|
||||||
// Device.init() initializes OS-Device values
|
// Device.init() initializes OS-Device values
|
||||||
Device.init();
|
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() to initalize location
|
||||||
|
Device.Location.init();
|
||||||
|
|
||||||
//Device.Acceleration.callback = updateAccel;
|
//Device.Acceleration.callback = updateAccel;
|
||||||
}
|
}
|
||||||
@ -44,12 +45,18 @@ updateSettings = function() {
|
|||||||
$('uuid').value = Device.uuid;
|
$('uuid').value = Device.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLocation = function(lat,lon) {
|
updateLocation = function(lat, lon) {
|
||||||
alert('lat=' + lat + ' lon=' + lon);
|
// updateLocatin based on user input
|
||||||
|
|
||||||
|
|
||||||
$('lat').value = lat;
|
$('lat').value = lat;
|
||||||
$('lon').value = lon;
|
$('lon').value = lon;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updateAccel = function(){
|
updateAccel = function(){
|
||||||
$('accelx').value = accelX;
|
$('accelx').value = accelX;
|
||||||
$('accely').value = accelY;
|
$('accely').value = accelY;
|
||||||
@ -70,7 +77,7 @@ addLoadEvent(initGap);
|
|||||||
|
|
||||||
<ul id="home" title="Main" selected="true">
|
<ul id="home" title="Main" selected="true">
|
||||||
<li><a href="#system" onclick="updateSettings();return false;">System...</a></li>
|
<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="#geo" onclick="updateLocation();">Geo-Location...</a></li> -->
|
||||||
<li><a href="#accel" onclick="updateAccel();">Accelerometer...</a></li>
|
<li><a href="#accel" onclick="updateAccel();">Accelerometer...</a></li>
|
||||||
<li><a href="#vibration" onclick="Device.vibrate();">Vibration</a></li>
|
<li><a href="#vibration" onclick="Device.vibrate();">Vibration</a></li>
|
||||||
@ -114,25 +121,26 @@ addLoadEvent(initGap);
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="geo" title="Geo Location" class="panel">
|
<div id="geo" title="Geo Location" class="panel" >
|
||||||
<form id="searchForm" action="POST">
|
|
||||||
<h2>Location</h2>
|
<h2>Location</h2>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label>Lat</label>
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label>Lon</label>
|
<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>
|
||||||
<div class="row">
|
<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>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="accel" title="Accelerometer" class="panel">
|
<div id="accel" title="Accelerometer" class="panel">
|
||||||
|
|
||||||
<h2>Accelerometer</h2>
|
<h2>Accelerometer</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user