Forum Discussion
GeoffreyHarmuth
7 years agoQrew Captain
So im stuck on this, is there anyone that can assist here? this code of Dans is not working.
Any help is appreciated.
Any help is appreciated.
AustinK
7 years agoQrew Commander
Lets start with the easy stuff. You have gone to what3words and created an api key correct? You have to register an account and possibly more, it says it is free. Then you replace the "Your API Key" part with your API key.
You also will need to edit that URL it is using. This code is using the v2 API but they are on v3 now.
https://api.what3words.com/v3/convert-to-coordinates?words=filled.count.soap&key=[API-KEY]
You can try this code here and see if it works with your API key. It should console.log the data which you can see by hitting f12 if in Chrome and going to the console tab.
var apikey = "YOUR API KEY";
var addr = "puns.chew.snow";
var url = 'https://api.what3words.com/v3/convert-to-coordinates?words=${addr}&format=json&key=${apikey....;
$.get(url)
.then(function(json) {
console.log(json.geometry.lat);
console.log(json.geometry.lng);
console.log(json.map);
console.log(JSON.stringify(json, null, " "));
});
You also will need to edit that URL it is using. This code is using the v2 API but they are on v3 now.
https://api.what3words.com/v3/convert-to-coordinates?words=filled.count.soap&key=[API-KEY]
You can try this code here and see if it works with your API key. It should console.log the data which you can see by hitting f12 if in Chrome and going to the console tab.
var apikey = "YOUR API KEY";
var addr = "puns.chew.snow";
var url = 'https://api.what3words.com/v3/convert-to-coordinates?words=${addr}&format=json&key=${apikey....;
$.get(url)
.then(function(json) {
console.log(json.geometry.lat);
console.log(json.geometry.lng);
console.log(json.map);
console.log(JSON.stringify(json, null, " "));
});