Thanks to your question. I am just about the time to find the method to query the full location name (if possible). Yesterday I tested it out for a while only, as I am still focusing on my speech flow (till now). Today I tested it again, and it works using google map API. However there is limit to number of query we can make per day.
Automagic itself already has built-in method to query location name, which you have used. (It seems to use the same google map API, but using developer API key). After getting the location coordinate (in latlong format) from Init Variable Location, simply show it in locationformat.
Code: Select all
fulladdress = "{location,locationformat}";
There is other format too, such as multiline; but I tested it out and it doesn't show the name in administrative order.
That's why I use google map API for geocode. I found it from tasker thread, but there is documentation too from google. What you need is only the latlong coordinate (location) from the init location, and pass it thru the API using HTTP request.
Action :
HTTP Request
URL :
https://maps.googleapis.com/maps/api/ge ... nsor=false
All other fields leave default
The result is response will contains the JSON response from the API. We can then parse the JSON to get the info we want. Unlike tasker, where the JSON parsing is a nightmare; Using Automagic, it is easy as piece of cake, as it is very JSON-friendly. Simply convert it to object by using fromJSON() and then browse to the value you want and you only need single line of script per information you need. It is a combination of map and list. The result shows you a list of address query from street name, area level 4, 3, 2, 1 up to country. Most of the information are available in the street name though, since it covers all. For example, you want the city/town, it is at area level 2, at index 4 of the street name. While street name is at index 1.
Action Script
Code: Select all
js = fromJSON(response);
town = js["results"][0]["address_components"][4]["long_name"];
street = js["results"][0]["address_components"][1]["long_name"];
Don't be afraid for such a long nested script, it is actually very easy to understand. You can find the level which you need, by attaching condition debug dialog after the script. Find the js and change value, you will see two map. Dig down at results, change value, you see a lot of list. Change value at element 0, there is address_components, and so on till you find the value you need. I find the town and street (or any information from the json) using the same method. I don't memorize it at all, i still use the debug dialog to help me create this nested map/list assignment.
However, since there is a limited time of usage per day, you should be careful not to query too often. You might want to save the js to a glovar, so you can analyze it later at the glovar menu.
@Martin : I wish there is a format or function or Action, where we can query the location and get the result just like in the response above. Or maybe just directly return the list/map of the street, area level 4 up till country.