This is the code i am using for getting locations. But unfortunately it prints "failure call back " always.
var location_timeout = setTimeout(function(){alert('failed');}, 10000);
navigator.geolocation.getCurrentPosition(function(position) {
findInStore.isGeoLocationPos = position;
clearTimeout(location_timeout);
alert('Succ call back')
findInStore.onDirectionLocation(event);
},function(){clearTimeout(location_timeout);
alert('failure call back');});
Try
http://stackoverflow.com/questions/7350033/geolocation-not-working-in-safari
http://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt
and few more. But none helps. getCurrentPosition call fails. Any suggestions? I am not good at this.
Turn Wifi on on your computer and it will work. Safari use wifi to geolocalize your computer :-)
Related
Currently Im trying to do an automatic logon over rdp with the Internet Explorer.
Basically what I'm trying to do is opening an ActiveXObject which then calls cmdkey to store the credentials temporary
var ws = new ActiveXObject("WScript.Shell");
setTimeout(function(){
ws.Exec("cmdkey /delete:"+servername+" ");
}, 100);
setTimeout(function(){
ws.Exec("cmdkey /generic:"+servername+" /user:"+username+" /pass:"+password+"");
}, 500);
setTimeout(function(){
ws.Exec("mstsc /v:"+servername+"");
}, 800);
setTimeout(function(){
new ActiveXObject("WScript.Shell").Exec("cmdkey /delete:"+servername+" ");
}, 20000);
First I thought the problem would be the cmdkey delete running before the mstsc could establish the connection, but even with a 20s timeout it still wasn't really working.
With "Not really working" I mean it works on some computers and on some computers not. And this is either Account-based (on the computer) or just generally working on a computer. Why is that? (I can't tell)
I'm currently testing it on IE11.0.48 with the js running locally on xmapp.
Does someone know the problem? or am I doing something wrong? (OR would there even be a better solution for this?)
//EDIT1: ActiveX is allowed internally and the mstsc gets called everytime but the autologon is the thing that doesnt work (at least not everytime)
I am trying to use HTML geolocation to get my position. Funny thing is, it was working brilliantly until some seemingly random point in the day when it just stopped working. Now all I get is the error callback with a message:
Unknown error acquiring position
This happened on the day I first started to develop the app. It is a web app built in Node/Express. The browser I am using is Firefox v53 64-bit.
Location is allowed, and I have also tried a fix that I found online which involves going to about:config and changing geo.wifi.uri from:
https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_API_KEY%
to
https://www.googleapis.com/geolocation/v1/geolocate?key=test
This did not work for me.
This does however work on my phones Firefox app, but not the Google Chrome app.
Heres an example code snippet:
const geo = navigator.geolocation;
geo.getCurrentPosition(success, failure);
function success(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
$('#coords').val(lat + ',' + lng);
mapView.setCenter(ol.proj.fromLonLat([lng, lat]));
}
function failure(error) {
console.log(error.message);
}
The full page: https://github.com/ThriceGood/Spots/blob/master/views/index.html
Can anyone shed some light on this issue?
What worked for me was changing geo.wifi.uri to:
https://location.services.mozilla.com/v1/geolocate?key=test
As per this page: navigator.geolocation.getCurrentPosition do not work in Firefox 30.0
I am trying to use MIDI.js to play sounds in the browser.
https://github.com/mudcube/MIDI.js
It works in the chrome browser on one of my computers, but not on my other one (which is a chromebook), or on the chrome browser on two of my friends computers.
it prints to the console
"uh-oh! Something went wrong! Error code: 1" MIDI.js:349
which refers to this part of MIDI.js
navigator.requestMIDIAccess(function (access) {
plugin = access;
output = plugin.getOutput(0);
if (callback) callback();
}, function (err) {
console.log("uh-oh! Something went wrong! Error code: " + err.code );
});
i found this post which seems to be referring to the problem i'm experiencing but i'm not quite sure
https://plus.google.com/+ChrisWilson/posts/cs4J6sS9qmJ
where it says to swap some parts of the code for some reason I couldn't understand
navigator.requestMIDIAccess( successCallback, failureCallback );
becomes:
navigator.requestMIDIAccess().then( successCallback, failureCallback );
but after replacing that part on MIDI.js 344, i get the error message
Uncaught TypeError: Cannot call method 'then' of undefined
Any help on how to fix this problem so it works in all browsers, or at least all chrome browsers, would be greatly appreciated. Thankyou
Chromebooks don't have Web MIDI API support yet (nor on Mac or Windows if you don't enable it, or Windows if you're not running Canary).
I have the following JavaScript in my page to get the location of the user:
state.currentTimer = navigator.geolocation.watchPosition(success, error, { enableHighAccuracy: true, maximumAge: 5000 });
It is intended that the page is called from the browser on a mobile phone. However the watchPosition method seems incredibly unreliable. Sometimes it won't ever get a location, other times the location is massively off, sometimes it will work fine and then just stop.
I have tried to eliminate the problem of the phones signal by testing it in a city with a good signal.
Is there a better way to get the location from a mobile while in the browser?
I use :
navigator.geolocation.getCurrentPosition(
function(pos) {
pos.coords.latitude;
pos.coords.longitude;
pos.coords.accuracy;
},
function(error) {
error.code;
}
);
All infos are here http://dev.w3.org/geo/api/spec-source.html
Really, that's the only way right now. To ensure that you get more accurate results, you can check the accuracy property of the object passed to your success handler.
I'm working on a script that needs to grab my geolocation. It works most of the time, However every now and then the geolocation is not aquired and I have to restart the browser for it to work again. This occurs in Safari and FF (Not tested in IE and Chrome). Does anybody know what could be causing this? I'm using this bit of code from the book "HTML 5".
<script type="text/javascript">
function loadDemo() {
if(navigator.geolocation) {
document.getElementById("status").innerHTML = "HTML5 Geolocation is supported in your browser.";
navigator.geolocation.getCurrentPosition(updateLocation);
}
}
function updateLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
if (!latitude || !longitude) {
document.getElementById("status").innerHTML = "HTML5 Geolocation is supported in your browser, but location is currently not available.";
return;
}
document.getElementById("latitude").innerHTML = latitude;
document.getElementById("longitude").innerHTML = longitude;
}
FF sometimes hangs, don't know about safari. It doesnt work in IE yet as far as i know. It seems to work great in Chrome so far.
You can "solve" this by setting a timeout. It still doesn't work but at least the script is terminated after a while. I use this code.
If you you found a good fix please let me know.
navigator.geolocation.getCurrentPosition(
function(position) {
//succes handler
},
function errorCallback(error) {
//error handler
},
{
enableHighAccuracy:false,
maximumAge:Infinity,
timeout:5000
}
);