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 6746167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:17:28+00:00 2026-05-26T12:17:28+00:00

I want to get the latitude and longitude from the result object returned by

  • 0

I want to get the latitude and longitude from the result object returned by geocoder.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Smart Minds</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 4,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }

  function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location
        });



        var inp=results[0].geometry.location;


        alert(inp);
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }
</script>
</head>
<body onLoad="initialize()">


  <!--</div>-->
<!--<div id="map_canvas" style="height:80%;top:30px;right:40%;left:20%"></div>-->
 <div id="map_canvas" style="border-width:0;width:500px;height:500px;left:40px;right:60px;top:20px"></div>

  <input id="address" type="textbox" value="" style="margin-top:60px;margin-left:400px;" placeholder="Enter your Location">
    <input type="button" value="Get me There" onClick="codeAddress()">
</body>
</html>

The results[0].geometry.location contains both the latitude and the longitude but I want to get separate values of longitude and latitude. I had tried to use a javascript function like split() and slice() on results[0].geometry.location but that is not working. Can anyone please tell me how I can do that?

  • 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-26T12:17:28+00:00Added an answer on May 26, 2026 at 12:17 pm

    You should be able to access the individual values like this:

    var lat = results[0].geometry.location.lat();
    var lng = results[0].geometry.location.lng();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get zip code from users current location(Latitude, Longitude), I had used
I want to get latitude and longitude from address in one of my asp.net
I want to get longitude & latitude from a json. to do so i
I want to get latitude and longitude of a city by providing the API
Possible Duplicate: get current latitude and longitude from gps enabled device I use the
I want to get the longitude and latitude of device. I used location api
I want to find country, city, latitude and longitude from IP address using php.
I get latitude and longitude values as geocoder results by using codes I got
Hello, I want to search place based on latitude, longitude, radius and name of
I have an application in Android which get latitude and longitude from GPS. 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.