@mathiasRobinson wrote:
Hello, im using the cordova-plugin-geolocation 1.0.1 for geolocation
when i hit the button that starts the location it works perfectly gets the location and program goes on.
how ever what i want is that i can press the button again and it should find the new location.
I testet the app the other day while driving hitting the button randomly but the locations i get in my log are all from the first time i press and i dont understand whyAssumeing the options maximumAge and timeout is in miliseconds, where maximumAge is for when its last allowed to be used, and timeout is a timeout for trying to get positio
function postLocation() { $scope.address = ""; //onSuccess Callback //This method accepts a Position object, which contains the //current GPS coordinates; var onSuccess = function (position) { 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 + '\n'); var url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + position.coords.latitude + "," + position.coords.longitude; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { jsonArr = JSON.parse(xmlhttp.responseText); $scope.address = jsonArr["results"][0]["formatted_address"]; Texting.sendSms([jsonArr["results"][0]["formatted_address"], position.coords.latitude + "," + position.coords.longitude]); } } xmlhttp.open("GET", url, true); xmlhttp.send(); } var options = { maximumAge: 3000, timeout: 15000, enableHighAccuracy: true }; //onError Callback receives a PositionError object function onError(error) { alert('kode: ' + error.code + '\n' + 'Besked: ' + error.message + '\n'); } navigator.geolocation.getCurrentPosition(onSuccess, onError, options); }
I hope theres some of you who can tell me why this is
Posts: 1
Participants: 1