byronigoe commented on issue #294:
URL:
https://github.com/apache/cordova-plugin-geolocation/issues/294#issuecomment-3954873490
I appreciate your response, but there is a fundamental disconnect. I just
created a new app from scratch and see the same behavior (no response from
navigator.geolocation.getCurrentPosition() and no map pin icon in the status
bar).
1. `cordova create hello com.example.hello HelloWorld`
2. `cd hello`
3. `cordova platform add android`
4. `cordova plugin add cordova-plugin-geolocation`
5. Edit index.html to add a button:
```html
<div>
<p id="gps" class="event">GPS</p>
</div>
```
6. Edit index.js to call the plug-in:
```javascript
document.getElementById('gps').addEventListener('click', getGPS);
function getGPS() {
console.log('Getting GPS');
document.getElementById('gps').classList.add('active');
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position) {
document.getElementById('gps').classList.remove('active');
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp);
}
function onError(error) {
document.getElementById('gps').classList.remove('active');
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
```
7. Edit index.css for styling:
```css
.event#gps {
background-color:#ba3529;
display:block;
}
.event#gps.active {
background-color:#2b20be;
}
```
8. `cordova build`
9. `adb install platforms\android\app\build\outputs\apk\debug\app-debug.apk`
10. Turn on Airplane Mode, and make sure Wi-Fi is also off.
11. Tap the GPS button.
12. The app will prompt for location permission, which should be granted.
13. The GPS button turns blue, never turns red again, and never alerts. The
status bar never shows the map pin icon, which confirms that it's not really
trying to get the location.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]