Json location geocoding

Hi,
i’m trying to geocoding with locationiq

these are my blocks

i have to extract from this string of json

`[{"place_id":"330420772163","licence":"https:\/\/locationiq.com\/attribution","lat":"40.827675","lon":"14.203342","display_name":"25, Via Giacomo Leopardi, Rione Lauro, Naples, Napoli, Italy, 80125","boundingbox":["40.827675","40.877063","14.203342","14.308822"],"importance":0.25},{"place_id":"331827903224","licence":"https:\/\/locationiq.com\/attribution","lat":"40.877063","lon":"14.308822","display_name":"25, Via Giacomo Leopardi, Arcamone, Naples, Napoli, Italy, 80026","boundingbox":["40.827675","40.877063","14.203342","14.308822"],"importance":0.25}]`

i knew it’s wrong but i can’t find any tutorial about that

1 Like

This post was flagged by the community and is temporarily hidden.

i just copied the response content

Your response content is a JSON array which contains json objects. You must iterate it to get your marks parameters

you mean something like that?

in “get text from json” i indicate 3 as index cause latitude is in that position…i think

You want to make a cluster of markers?

yes, i search a location using an address (eg 25, via luigi mercantini 100, na, 80125, campania, italia) and i have in return a jason array, in which normally there are two objects (two location) and i want them to show in the map, then i click on the right location i want to pick

Ok.
First you have to diferenciate json object from json array.
A json array is a list of values, comma separated betwen square parenthesis [ ]. The value can be anything. [value1,value2,value3]
A json object is a list of pair key:value separated by comma, between this parenthesis { tag1:value1, tag2:value2, … }.

In your particular case you have:

[
{
“place_id”:“330420772163”,
“licence”:“Attribution - LocationIQ”,
“lat”:“40.827675”,
“lon”:“14.203342”,
“display_name”:“25, Via Giacomo Leopardi, Rione Lauro, Naples, Napoli, Italy, 80125”,
“boundingbox”:[“40.827675”,“40.877063”,“14.203342”,“14.308822”],
“importance”:0.25
},
{
“place_id”:“331827903224”,
“licence”:“Attribution - LocationIQ”,
“lat”:“40.877063”,
“lon”:“14.308822”,
“display_name”:“25, Via Giacomo Leopardi, Arcamone, Naples, Napoli, Italy, 80026”,
“boundingbox”:[“40.827675”,“40.877063”,“14.203342”,“14.308822”],
“importance”:0.25
}
]

Two json objects inside a json array, so we have to iterate inside them.

Next step is to fill the markers

4 Likes

that’s pure gold.
no other topic like that are in this forum, it’s pretty easy knowing how to do, and you explained very well.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.