Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7189589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:20:05+00:00 2026-05-28T19:20:05+00:00

Trying to read in some information from the google maps api into my application

  • 0

Trying to read in some information from the google maps api into my application with JS. But havent quiet got my head around accessing the information in the returned jSON object.
My JS is…

        var site = "./maps/scripts/reverseGeocode/locale.php";
        var params = "lat="+lat+"&"+"lng="+lng;

        var object = system.functions().ajax(site, params);

            var result = object.address_components[0];

          alert(result);

The jSON object is as follows…

  {
    "results" : [
      {
     "address_components" : [
        {
           "long_name" : "24",
           "short_name" : "24",
           "types" : [ "street_number" ]
        },
        {
           "long_name" : "Carabella St",
           "short_name" : "Carabella St",
           "types" : [ "route" ]
        },
        {
           "long_name" : "Kirribilli",
           "short_name" : "Kirribilli",
           "types" : [ "locality", "political" ]
        },
        {
           "long_name" : "New South Wales",
           "short_name" : "NSW",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "Australia",
           "short_name" : "AU",
           "types" : [ "country", "political" ]
        },
        {
           "long_name" : "2061",
           "short_name" : "2061",
           "types" : [ "postal_code" ]
        }
     ],
     "formatted_address" : "24 Carabella St, Kirribilli NSW 2061, Australia",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : -33.84886950,
              "lng" : 151.21871730
           },
           "southwest" : {
              "lat" : -33.84960880,
              "lng" : 151.21810640
           }
        },
        "location" : {
           "lat" : -33.84892950,
           "lng" : 151.21817770
        },
        "location_type" : "RANGE_INTERPOLATED",
        "viewport" : {
           "northeast" : {
              "lat" : -33.84789016970850,
              "lng" : 151.2197608302915
           },
           "southwest" : {
              "lat" : -33.85058813029150,
              "lng" : 151.2170628697085
           }
        }
     },
     "types" : [ "street_address" ]
  },
  {
     "address_components" : [
        {
           "long_name" : "Kirribilli",
           "short_name" : "Kirribilli",
           "types" : [ "locality", "political" ]
        },
        {
           "long_name" : "New South Wales",
           "short_name" : "NSW",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "Australia",
           "short_name" : "AU",
           "types" : [ "country", "political" ]
        },
        {
           "long_name" : "2061",
           "short_name" : "2061",
           "types" : [ "postal_code" ]
        }
     ],
     "formatted_address" : "Kirribilli NSW 2061, Australia",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : -33.84245090,
              "lng" : 151.22032150
           },
           "southwest" : {
              "lat" : -33.85270230,
              "lng" : 151.21152060
           }
        },
        "location" : {
           "lat" : -33.84753980000001,
           "lng" : 151.21314540
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : -33.84245090,
              "lng" : 151.22032150
           },
           "southwest" : {
              "lat" : -33.85270230,
              "lng" : 151.21152060
           }
        }
     },
     "types" : [ "locality", "political" ]
  },
  {
     "address_components" : [
        {
           "long_name" : "2061",
           "short_name" : "2061",
           "types" : [ "postal_code" ]
        },
        {
           "long_name" : "New South Wales",
           "short_name" : "NSW",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "Australia",
           "short_name" : "AU",
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "New South Wales 2061, Australia",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : -33.84234370,
              "lng" : 151.22032150
           },
           "southwest" : {
              "lat" : -33.85270230,
              "lng" : 151.20932150
           }
        },
        "location" : {
           "lat" : -33.84839570,
           "lng" : 151.21461550
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : -33.84234370,
              "lng" : 151.22032150
           },
           "southwest" : {
              "lat" : -33.85270230,
              "lng" : 151.20932150
           }
        }
     },
     "types" : [ "postal_code" ]
  },
  {
     "address_components" : [
        {
           "long_name" : "New South Wales",
           "short_name" : "NSW",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "Australia",
           "short_name" : "AU",
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "New South Wales, Australia",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : -28.15619210,
              "lng" : 153.63873290
           },
           "southwest" : {
              "lat" : -37.50503180,
              "lng" : 140.99921220
           }
        },
        "location" : {
           "lat" : -31.25321830,
           "lng" : 146.9210990
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : -28.15619210,
              "lng" : 153.63873290
           },
           "southwest" : {
              "lat" : -37.50503180,
              "lng" : 140.99921220
           }
        }
     },
     "types" : [ "administrative_area_level_1", "political" ]
  },
  {
     "address_components" : [
        {
           "long_name" : "Australia",
           "short_name" : "AU",
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "Australia",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : -9.22108360,
              "lng" : 159.10545890
           },
           "southwest" : {
              "lat" : -54.77721850,
              "lng" : 112.92145430
           }
        },
        "location" : {
           "lat" : -25.2743980,
           "lng" : 133.7751360
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : -9.22108360,
              "lng" : 159.10545890
           },
           "southwest" : {
              "lat" : -54.77721850,
              "lng" : 112.92145430
           }
        }
     },
     "types" : [ "country", "political" ]
  }
  ],
  "status" : "OK" 
 }

I am trying to access the address component… but am unsure how to traverse the object correctly.. could someone help me.

           "long_name" : "Kirribilli",
           "short_name" : "Kirribilli",
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:20:06+00:00Added an answer on May 28, 2026 at 7:20 pm

    This should do it:

    var long_name = object.address_components[2].long_name;
    var short_name = object.address_components[2].short_name;
    

    EDIT: suggest you use jquery ajax instead for the fetch:

    var site = "./maps/scripts/reverseGeocode/locale.php";
    var params = "lat="+lat+"&"+"lng="+lng;
    
    $.get(site + '/' + params, function(data) {
        var long_name = data.address_components[2].long_name;
        var short_name = data.address_components[2].short_name;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read some settings from php.ini using zend. The API that
I am trying to read product information from some text files. In my text
I'm trying to scrape some information from a website but can't find a solution
I am trying to read some info from a text file by using windows
I'm trying to read in some sample data from an XML file in a
I am trying to read command lien argument but it seems there is some
I'm trying to create a list of tasks that I've read from some text
I am trying to code an simple PHP application which will retrieve some information
I have a problem with the SQLite3 C API. I'm trying to read some
Im trying to use JSON.NET framework in a windows Form to read some information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.