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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:51:34+00:00 2026-05-16T03:51:34+00:00

I have a geocoding function that is pulling the address values entered into a

  • 0

I have a geocoding function that is pulling the address values entered into a form and putting them into the geocoding call. The response is supposed to write the latitude & longitude values into the DB – unfortunately, my lat & longs are all coming back as Antarctica. Thoughts?

//Set up our variables
$longitude = "";
$latitude = "";


//Three parts to the querystring: q is address, output is the format (
$key=$er_mapapi; 
$address=str_replace(' ', '%20', $_REQUEST['street_num'] . ' ' . $_REQUEST['address2'] . ', ' . $loccity . ', ' . $ststate . ', ' . $_REQUEST['postcode'] . ', ' . $cncount); 
$url = "http://maps.google.com/maps/geo?q=".$address."&output=json&key=".$key;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data = curl_exec($ch);
curl_close($ch);

$geo_json = json_decode($data, true);

print_r($geo_json);

if ($geo_json['Status']['code'] == '200') {


$latitude = $geo_json['Placemark'][0]['Point']['coordinates'][0];
$longitude = $geo_json['Placemark'][0]['Point']['coordinates'][1];


echo "Latutide: $latitude \n";
echo "Longitude: $longitude \n";

if ($latitude != '') $row->declat = $latitude; if ($longitude != '') $row->declong = $longitude; 


} else {
echo "Error in geocoding! Http error ".substr($data,0,3);
}
  • 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-16T03:51:35+00:00Added an answer on May 16, 2026 at 3:51 am

    There may be other errors, but to start it looks like KML returns point coordinates in (long, lat) order, and you’re expecting the opposite.

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

Sidebar

Related Questions

I have an App that does forward geocoding (get coordinates given address) to display
I have this code that triggers when a form is submitted: $(form).submit(function (e) {
I have a form in which an address will be entered and I want
I have a function that is set up as follows function mainFunction() { function
We are using reverse-geocoding in a rails webservice, and have run into quota problems
Let's say I have these geocoding calls: function myFunction(marker1,marker2) { var firstAddress = null;
I have a simple object that get's geocoding data from the Google Maps API
I have been coding around with Google Geocoding until I found out that the
I've got a form to get an address from a user, and send that
I have xml file that contains the URLs for geocoding requests to Google. 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.