How do I get a geolocate api jey?
I want to use Mozilla geolocate on a web page as the Google one requires https - how do I obtain the Mozilla api-key? Thank You
Alla svar (11)
See these MDN pages.
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation
I would be surprised if the Firefox Geolocation API worked on HTTP.
I need an api key to try it! How do I get one? Yjanx
Oops, thanx I meant!
I am using https://location.services.mozilla.com/v1/geolocate?key=test but get status 0 - invalid key?
Works for me: https://location.services.mozilla.com/v1/geolocate?key=test
- {"location": {"lat": xx.xxxx, "lng": x.xxxx}, "accuracy": 1000.0}
Not for me! var url = 'https://location.services.mozilla.com/v1/geolocate?key=test'; xhr.open('GET', url); xhr.setRequestHeader('Content-type', 'application/json'); Gives readystate:4 status:0 and "text" in text!
var url = 'https://location.services.mozilla.com/v1/geolocate?key=test'; var xhr=new XMLHttpRequest(); xhr.open("GET",url,true); xhr.onload=function(e){if(xhr.readyState===4){if(xhr.status===200){console.log(xhr.responseText)}else{console.error(xhr.statusText)}}}; xhr.onerror=function(e){console.error(xhr.statusText)}; xhr.send(null);
Yes and I get - readystate:4 status:0 text when I log the 3 fields to console, which implies invalid key! Possibly it's because I'm in Thailand?
Does it work at least when you visit a website that uses geolocation?
Thanx. I've no sensor on the pc but, Google maps does get the approximate location though this obviously uses https!