Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

Learn More

How do I get a geolocate api jey?

  • 11 réponses
  • 1 a ce problème
  • 8 vues
  • Dernière réponse par 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

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

Toutes les réponses (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!