Get data(street name) from geocoder google api

Ok I send link. Thanks!

1 Like

Good.

1 Like

Reply wrote to you in a message.

Solucion:


Muchas gracias actech!

2 Likes

Hi! I’m having a problem similar to David’s above. I tried to replicate the blocks but I’ve still got a white screen in CrossPlatform. I have a JSON file in a realtime db on Firebase. I’m trying to retrieve the value of -facilityName.

Here is my file:

Here are my blocks:

Thanks,
Teri

1 Like

Hi Teri,

You did the right thing, using the shown example. But you need to not just copy the blocks, but to indicate the correct field names that differ from the example of David. If you want me to do blocks for you, then give me a link to your project. If you want to learn how to solve such problems, I can explain it.

Alex

1 Like

Thanks! I’d appreciate understanding the problem so please explain.

1 Like

The problem of obtaining the value of a field in a JSON format is finding the right path. If you specify an incorrect path, there will be a white screen. This is similar to how you search for a file in folders:

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

Look at your data in JSON format. They consist of nested into each other of objects that are between the symbols { and }. { … } is one whole object. And some of the objects are between the symbols [ and ], for example:

[
{},
{},
{}
]

This is a list of objects, which is 3 object.

Inside the object, you see a pair “key”:”value”. To get the value you need to specify the key. The key is what is left of the symbol “:”.

What key corresponds to the desired value ADELAIDE CAMPGROUND? Key –facilityName. We write it

–facilityName

See above and do you see a bracket [. This means our object with key –facilityName is in the list of objects. What number? Numbering items in a list starts from 1. So our target is number 1. We write it:

–facilityName → 1

And the list is on what key? result! We write it:

–facilityName → 1 → result

As an object with a key result is what object? resultset! We write it:

–facilityName → 1 → result → resultset

resultset is on what key? Any which is the root key, and above it nothing. So the path to the desired value like this:

–facilityName → 1 → result → resultset

Now it needs to be turned into blocks. Get this:

Label1.Text < –facilityName < 1 < result < resultset < get object from JSON < value

You understand how to construct the path? You can not skip steps in the path, but you can look at the values ​​after each step to check if you are going to the correct object or not.

Imagine that you need to give the letter to a person with the name ADELAIDE CAMPGROUND. What room is she in? You enter the building “resultset”, then come to the elevator with title “result”, press the first floor, go down the hall and knock on the door “–facilityName”.

2 Likes

Thanks, Alex. That makes complete sense to me. I had all of those blocks in place except the resultset one. I thought I might not need that one because I was using resultset as my key in the get call to the database. However, even plugging that resultset block in I’m still getting a white screen. Is it perhaps a problem with that call to the database? I’ll send you a link to my project.

Hm, actually I don’t see how to send you a link. It says I can’t send that user (you) a private message.

1 Like

1 Like

Thank you so much, actech!

Here are the two possible solutions that he gave me:

Further on in this project, I’m having trouble looping through my JSON and populating a list with the values. Here’s a snippet of my JSON:

For instance, these blocks will retrieve the facilityName Antelope Valley RV Park and display it:

However, when I try to loop through the entire JSON and return back all the appropriate facilityNames, I get nothing:

I’d appreciate any advice you can give me!
Teri

1 Like

This problem is well described and solved by Mark. You need to adapt the solution shown for your case.

If you don’t want to deal with asynchronous blocks, you can use this solution:

  1. Keep all the required amount of data in the list
  2. Create a loop on the list to perform the desired action.
1 Like

Thanks. I found a solution before I saw your reply. It seems like it was the nested calls to the database that was causing the problem. Once I figured out how to get ALL the information that I wanted in one call, the loop worked fine.

1 Like

estou tendo a mesma dificuldade… preciso so da distancia


mais nao to conseguindo… meus blocos abaixo

se puderem me ajudar… a explicaçao do actech eu entedi mais o meu nao acontece nada…

1 Like

ja consegui !!!

1 Like

Hey there… again. I am so sorry to bother y´all but I am sure I´ve follwed your instructions and I don´t know why this thing is still messed up.

This is my json file

[
{
“Answer”: “Answer A”
},
{
“Answer”: “Answer B”
},
{
“Answer”: “Answer C”
},
{
“Answer”: “Answer D”
}
]

This is my design in which you can see the local file is uploaded

And these are my blocks

I´ve tried different file extensions: .js , .json and .txt
And I don´t know why on my app Label still says “Label”

I´d appreciate your help

1 Like

David,

The key that you use in your Local Storage Get block needs to be exactly that same as the key that you presumably used in a Local Storage Save block somewhere else in your app.

In the meantime, you might want to first just set your label to the JSON value returned by your Local Storage Get block (you might also want to increase the width and height of the label so that it will fit all the JSON). Assuming that the JSON looks good, you might then want to display the result of your 'get property ...' blocks (you can use 'generate JSON from object' to convert that value to displayable JSON). Doing these steps will help you to debug your blocks and see where the error might be.

If none of the above help, could you post a share/copy link of your project (here’s how)? That might allow us to give you more help.

-Mark

2 Likes

Im able to extract the place names of my surrounding location, but i need the photo reference as well which is in the json list from the api but now i need also extract the phto reference, why can i do it with “name” but not “photo reference” - what json path am i missing?

see the blocks pls:

also this is what my json result looks like from the url:

{
“html_attributions” : ,
“next_page_token” : “CqQCFwEAAPlMLjSfkOtUDbFa7SSiMqDp6_tUGbCLDmM4euas9MrP51PZCSVx3GtKlYXRdritUYz4WA_qkBbBZ_5b833VV5sPPNHJeDt9otfDuNXSVKuuY-MvTcGAlwCqjxSAxtaA5SHn05PP1kr-IAMoN8yknh7gAIKAbX6i86cKfhw6SGPgfSxo6BMyWlYfriJqcReqES2sNtsqQ0DR6SkAzZDoPdAR8qt9ehLSWPeE8Pe3H6i7GOXE2Df_Jvf_gZiQC0rH_ytGBtUnEBWvJwZyzqqnqhWg1V2AuB7QXQseJtoDZgyDYWN3vJNMdqB8yOtYkLOZ4Q6M9ANZ-LIcod2Og56kWpb8c_DOSY8o6WhfJdGiylKvXfTdUa4UtoV-c3ypY6iLZRIQI7DCTqEqXFOyB_nmxuBoaBoUkkt7hymQyGtfVAf4RfajiJ1TMu8”,
“results” : [
{
“geometry” : {
“location” : {
“lat” : -29.7870389,
“lng” : 31.02204219999999
},
“viewport” : {
“northeast” : {
“lat” : -29.7457011,
“lng” : 31.0673288
},
“southwest” : {
“lat” : -29.8121719,
“lng” : 30.990419
}
}
},
“icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png”,
“id” : “2481b08a523fa7dfcc52339521fb6289d93880cf”,
“name” : “Durban North”,
“photos” : [
{
“height” : 1836,
“html_attributions” : [
“\u003ca href=“https://maps.google.com/maps/contrib/116936888055646766012/photos”\u003emuhummed bhayla\u003c/a\u003e”
],
“photo_reference” : “CmRaAAAA4fDIxCIg1tlptb_xfUweNmPIb8yXE64UbcDO_5CFVi2la0RbXC6qUAT2cumALD4akUQep1ug8BJ9K9dpT7uGvm53MFfVoXgjnByRpVWRiYZIMp0XbHnQVbokD86IRGdMEhAyubYZ7nLSGPkRUIuTHO45GhQN1A34hZaQYZMl4mrreOlqcvv_gA”,
“width” : 3264
}
],
“place_id” : “ChIJ04EcnZEG9x4Rr-9fNPScsTo”,
“reference” : “ChIJ04EcnZEG9x4Rr-9fNPScsTo”,
“scope” : “GOOGLE”,
“types” : [ “locality”, “political” ],
“vicinity” : “Durban North”
},
{
“geometry” : {
“location” : {
“lat” : -29.771907,
“lng” : 31.037212
},
“viewport” : {
“northeast” : {
“lat” : -29.7705679697085,
“lng” : 31.03858208029149
},
“southwest” : {
“lat” : -29.7732659302915,
“lng” : 31.03588411970849
}
}
},
“icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png”,
“id” : “44ef45566537d9237dd047767a98a100d72b8584”,
“name” : “Duikerfontein B & B”,
“photos” : [
{
“height” : 2988,
“html_attributions” : [
“\u003ca href=“https://maps.google.com/maps/contrib/115866465107119235256/photos”\u003eRudi Rabie\u003c/a\u003e”
],
“photo_reference” : “CmRaAAAAgxNwa1D-bHFzlZD5uB0-4uOjXkD5BB4uIUM72lD6zmvMbONo_UpMgSHE1Y5_jsAkdT44XOWalmNI4H9jV8RgerJ5AuXvfn-S7dXkHhNeieN7EXFM2IlUsiejCNAMiUb9EhBh4lpRTbgcf6H0Y5a5H0AtGhT26GIRsf-gvvHaU9_Icolgraa_xg”,
“width” : 5312
}
],
“place_id” : “ChIJM1QVkGAG9x4R_I_fl0FSqq8”,
“plus_code” : {
“compound_code” : “62HP+6V Durban North, South Africa”,
“global_code” : “5G2H62HP+6V”
},
“rating” : 4.6,
“reference” : “ChIJM1QVkGAG9x4R_I_fl0FSqq8”,
“scope” : “GOOGLE”,
“types” : [ “lodging”, “point_of_interest”, “establishment” ],
“vicinity” : “135 Umhlanga Rocks Drive, Durban North, Durban”
},
{
“geometry” : {
“location” : {
“lat” : -29.776884,
“lng” : 31.037772
},
“viewport” : {
“northeast” : {
“lat” : -29.7753892197085,
“lng” : 31.0391405802915
},
“southwest” : {
“lat” : -29.7780871802915,
“lng” : 31.0364426197085
}
}
},
“icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png”,
“id” : “36e7d67cadae264c1c70b747b78d72a8ac2c4dd6”,
“name” : “Beachway Cottages”,
“place_id” : “ChIJNzllx14G9x4RvArtT5M0eC8”,
“plus_code” : {
“compound_code” : “62FQ+64 Durban North, South Africa”,
“global_code” : “5G2H62FQ+64”
},
“rating” : 5,
“reference” : “ChIJNzllx14G9x4RvArtT5M0eC8”,
“scope” : “GOOGLE”,
“types” : [ “lodging”, “point_of_interest”, “establishment” ],
“vicinity” : “12 Beachway, Durban North, Durban”
},
{
“geometry” : {
“location” : {
“lat” : -29.776306,
“lng” : 31.034142
},
“viewport” : {
“northeast” : {
“lat” : -29.7750286197085,
“lng” : 31.0356409302915
},
“southwest” : {
“lat” : -29.7777265802915,
“lng” : 31.0329429697085
}
}
},
“icon” : “https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png”,
“id” : “3e5c222446e9ae80f0508818d86e1d758f527e00”,
“name” : “Flying Solo”,
“opening_hours” : {
“open_now” : false
},
“place_id” : “ChIJLb7AeV8G9x4RfUAkEnb4zlk”,
“plus_code” : {
“compound_code” : “62FM+FM Durban North, South Africa”,
“global_code” : “5G2H62FM+FM”
},
“reference” : “ChIJLb7AeV8G9x4RfUAkEnb4zlk”,
“scope” : “GOOGLE”,
“types” : [ “travel_agency”, “point_of_interest”, “establishment” ],
“vicinity” : “39 Umhlanga Rocks Drive, Durban North”
},

1 Like