extract adresse from google map ?

Post your questions and help other users.

Moderator: Martin

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

extract adresse from google map ?

Post by joeko » 08 Jun 2019 07:44

Hallo,
I Start a voice search with automagic for an shop. Now google map Start and Show me the location with name of the shop.

Is IT possible to get only the adresse as result without the name of the Shop ?

For example

Search: toom Wandsbek Hamburg
Result : street 1 Hamburg

Can i save the search result from google maps as variable ?

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: extract adresse from google map ?

Post by joeko » 08 Jun 2019 12:37

or maybe change the Text from

toom Baumarkt
Am Stadtrand 31-33, 22047 Hamburg
040 6969710
https://maps.app.goo.gl/6w1Pq7Rkpjvy9HuN6

To

Am Stadtrand 31-33, 22047 Hamburg

This is finally what i want.
I try regex but i dont know how

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: extract adresse from google map ?

Post by Desmanto » 09 Jun 2019 06:18

How do you get the exact text from gmaps? Do you still need to share from Gmaps back to Automagic?

It seems the standard formatting from gmaps is
1st line : Place name
2nd line : address
3rd line : phone number or any extra info
4th line : gmaps link

If it is consistent, you can retrieve only the 2nd line using regex.

Code: Select all

find = findAll(text, '\\n(.*)\\n', true);
address = find[0][1];
\\n to match newline char
(.*) to match the whole line
By putting \\n then (.*) then \\n, we tell the regex to match a newline (must be after second line already), the whole line, then another newline. In short, match the second line of the text.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: extract adresse from google map ?

Post by joeko » 09 Jun 2019 07:09

Thx, IT works :)

Is there also a way to get the information without start gmaps ?
Maybe an http request with a answer from gmaps ?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: extract adresse from google map ?

Post by Desmanto » 15 Jun 2019 16:23

Do you mean you want to search for location and then return only the address from it? We can use Gmap geocode location API, but it is very limited for public user.
You can use nominatim openstreetmap API instead. You can look at here : viewtopic.php?f=5&t=7457
Maybe that is what you want. You can parse the json later and retrieve the address.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: extract adresse from google map ?

Post by joeko » 20 Jun 2019 12:51

hallo desmanto,

i mean : i start a Action : voice search
for example : toom Wandsbek Germany
and i get the adress from this shop and save the adress in a variable.

is that possible ?

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: extract adresse from google map ?

Post by joeko » 21 Jun 2019 11:55

Desmanto wrote:
15 Jun 2019 16:23
Do you mean you want to search for location and then return only the address from it? We can use Gmap geocode location API, but it is very limited for public user.
You can use nominatim openstreetmap API instead. You can look at here : viewtopic.php?f=5&t=7457
Maybe that is what you want. You can parse the json later and retrieve the address.
hmm, many thx for the answer but i dont know how i can do this ?
can you tell me how i can create this flow ?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: extract adresse from google map ?

Post by Desmanto » 23 Jun 2019 15:20

I don't use voice search, since it will open up google assistant. If you mean to use voice recognition in Automagic, I use action Input Speech, set the language. You can use no user interface to prompt without the mic icon. This will store the result in {value}. You can then use the {value} to query the address. The link I give you above is to reverse search base on location. We can use the normal search for this location name search.

Code: Select all

url = "https://nominatim.openstreetmap.org/search?q={value}&format=json&limit=1&addressdetails=1";
then use {url} in http request field. The result is in {response} which you can parse using

Code: Select all

js = fromJSON(response);
In the {js}, you can check the value by using condition debug dialog, dig down and find the address you want. However, the address format shown using osm query is a bit different than the google maps version. You need to see it first and tell me which one you need. From my finding, it is most likely this

Code: Select all

address = js[0]["display_name'];
// toom Baumarkt, 31,33, Am Stadtrand, Wandsbek, Hinschenfelde, Hamburg, 22047, Deutschland
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: extract adresse from google map ?

Post by joeko » 23 Jun 2019 20:13

thx for your help
Desmanto wrote:
23 Jun 2019 15:20
You need to see it first and tell me which one you need. From my finding, it is most likely this

Code: Select all

address = js[0]["display_name'];
// toom Baumarkt, 31,33, Am Stadtrand, Wandsbek, Hinschenfelde, Hamburg, 22047, Deutschland
from the js i Need in the order

road, house_number, city_district

i tried it with road but i gel only zero as result. in js i found this data in address
address={doityourself=toom Baumarkt, house_number=31,33, road=Am Stadtrand,
suburb=Wandsbek, city_district=Wandsbek, hamlet=Hinschenfelde,
state=Hamburg, postcode=22047, country=Deutschland, country_code=de}}]

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: extract adresse from google map ?

Post by joeko » 24 Jun 2019 12:02

i got it :-)
Little mistake only :)

many thx

Post Reply