hmm, all fine now but how i create a new variable with blank space between road and house_number ?
address = (road) + (house_number);
result is street1 and not street 1
extract adresse from google map ?
Moderator: Martin
Re: extract adresse from google map ?
If you check the result of the json in debug dialog, then choose to show it in json view, you will see something like this.
It is easier to know the hierarchy now. So if we parse it now, it becomes
Then if we want to add some space, you can add string with space in between, or just use inline variable.
Both give the same result, Am Stadtrand 31,33, Wandsbek
I prefer the + method when the variable is not final, I might append something later, or just for the purpose to see the variable easier.
I prefer the inline method when the variable is final, the address is ready to be shown in some display (example toast message or notification). Because using inline variable, makes it a bit difficult to spot the variable now, as the coloring is green and inside string.
Code: Select all
[{
"place_id": 79652320,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"osm_type": "way",
"osm_id": 23384770,
"boundingbox": [
"53.5868484",
"53.5878464",
"10.0977657",
"10.099514"
],
"lat": "53.58736045",
"lon": "10.0985517127999",
"display_name": "toom Baumarkt, 31,33, Am Stadtrand, Wandsbek, Hinschenfelde, Hamburg, 22047, Deutschland",
"class": "shop",
"type": "doityourself",
"importance": 0.21100000000000002,
"icon": "https://nominatim.openstreetmap.org/images/mapicons/shopping_diy.p.20.png",
"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"
}
}]
Code: Select all
road = js[0]["address"]["road"];
house_number = js[0]["address"]["house_number"];
city_district = js[0]["address"]["city_district"];
Code: Select all
address = road + " " + house_number + ", " + city_district ;
address = "{road} {house_number}, {city_district}";
I prefer the + method when the variable is not final, I might append something later, or just for the purpose to see the variable easier.
I prefer the inline method when the variable is final, the address is ready to be shown in some display (example toast message or notification). Because using inline variable, makes it a bit difficult to spot the variable now, as the coloring is green and inside string.
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.