Geocoder – find your latitude and longitude

Here is a quick way to find your latitude and longitude. It is a PHP script using the Google geocoding service. The Google Store Locator demo on this site utilizes the latitude and longitude from such a request to locate nearby Cyberstarweb locations. With this script as a start, you could build an entire site like

Here is the PHP source code of the geocoder.php


   if ($_POST['address'] != "") {

   doGeo($marker) {
   // Your Google Maps API key
   $key = "Your key here";
   // Desired address
   $address = "$marker&output=xml&key=$key";
   // Retrieve the URL contents
   $page = file_get_contents($address);
   // Parse the returned XML file
   $xml = new SimpleXMLElement($page);
// Retrieve the desired XML node
//   echo $xml->Response->Placemark->Point->coordinates;
   // Parse the coordinate string
   list($longitude, $latitude, $altitude) = explode($xml->Response->Placemark->Point->coordinates);

   // Output the coordinates
	echo($marker)." Longitude: $longitude, Latitude: $latitude";

One Response to Geocoder – find your latitude and longitude

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>