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

  • Home
  • SEARCH
  • 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 6635859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:06:36+00:00 2026-05-25T23:06:36+00:00

My simple android application uses google places api to get the latitude and longitude

  • 0

My simple android application uses google places api to get the latitude and longitude of a place. I am getting the json response from the google api as below

 {
   "results" : [

      {
         "address_components" : [
            {
               "long_name" : "Chennai",
               "short_name" : "Chennai",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Chennai",
               "short_name" : "Chennai",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Tamil Nadu",
               "short_name" : "TN",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Chennai, Tamil Nadu, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 13.23408510,
                  "lng" : 80.33229129999999
               },
               "southwest" : {
                  "lat" : 12.94592670,
                  "lng" : 80.14878270
               }
            },
            "location" : {
               "lat" : 13.0604220,
               "lng" : 80.2495830
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 13.14736150,
                  "lng" : 80.37764240
               },
               "southwest" : {
                  "lat" : 12.97345190,
                  "lng" : 80.12152360
               }
            }
         },
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

Now i want to get the this part in the json response,

"location" : {
           "lat" : 13.0604220,
           "lng" : 80.2495830
        }

I only get the whole “geometry” part as string through this method

JSONObject e = address.getJSONObject(0);
e.getString("geometry")

How to use the only location values. Any help is appreciated. I’m not sure what is going wrong.

  • 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-25T23:06:37+00:00Added an answer on May 25, 2026 at 11:06 pm
    JSONObject e = address.getJSONObject(0);
    JSONObject jsonLocation = e.getJSONObject("geometry").getJSONObject("location");
    

    and use

    String lat = jsonLocation.getString("lat");
    String lng = jsonLocation.getString("lng");
    

    to get latitude and longitude.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Naming Android mime-types/Uris: The sample notepad application uses: vnd.android.cursor.dir/vnd.google.note vnd.android.cursor.item/vnd.google.note Let's say I want
I have written a simple Android application that uses a sqlite database which is
I've been trying to create an application that uses Google Maps and upon getting
I have a simple Android application that uses an instance of a class, let's
I am developing sample application that uses Google Map API. I have generated Google
I developed one simple android application targeting the Mobiles with android 2.0 OS.I want
I am trying to create a simple Android application that has a ActivityList of
I'm new to Android development. I'm trying to get a simple HelloWorld app going
I am developing a simple android application using eclipse. I wrote a JUnit TestCase
I am trying to run the Task-Android-sample given at Google Api Java Client I

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.