Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

How do I get a geolocate api jey?

  • 11 replies
  • 1 has this problem
  • 42 views
  • Last reply by jag2jag

more options

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

All Replies (11)

more options

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.

more options

I need an api key to try it! How do I get one? Yjanx

more options

Oops, thanx I meant!

more options

I am using https://location.services.mozilla.com/v1/geolocate?key=test but get status 0 - invalid key?

more options

Works for me: https://location.services.mozilla.com/v1/geolocate?key=test

  • {"location": {"lat": xx.xxxx, "lng": x.xxxx}, "accuracy": 1000.0}
more options

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!

more options
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);
more options

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?

more options

Does it work at least when you visit a website that uses geolocation?

more options

Thanx. I've no sensor on the pc but, Google maps does get the approximate location though this obviously uses https!