<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cyberstarweb &#187; Geocoder</title>
	<atom:link href="http://cyberstarweb.com/tag/geocoder/feed/" rel="self" type="application/rss+xml" />
	<link>http://cyberstarweb.com</link>
	<description>Computer, Web, and Software Services</description>
	<lastBuildDate>Fri, 23 Jul 2010 01:16:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Geocoder &#8211; find your latitude and longitude</title>
		<link>http://cyberstarweb.com/2008/04/geocoder-find-your-latitude-and-longitude/</link>
		<comments>http://cyberstarweb.com/2008/04/geocoder-find-your-latitude-and-longitude/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 05:44:00 +0000</pubDate>
		<dc:creator>Cyberstarweb</dc:creator>
				<category><![CDATA[Geocoder]]></category>

		<guid isPermaLink="false">/post/Geocoder---find-your-latitude-and-longitude.aspx</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick way to find your latitude and longitude. It is a PHP script using the Google geocoding service. The <a href="http://cyberstarweb.com/category/Google-store-locator.aspx">Google Store Locator</a> 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 <a href="http://geocoder.us/" target="_new">geocoder.us</a>     </p>
<p> 
<p><iframe src="/mylocator/geocoder.php" frameborder="0" width="500" height="200"></iframe>    <br />Here is the PHP source code of the geocoder.php     </p>
<p>&#160;</p>
<pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb"><span style="color: #0000ff"><?</span>php
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   <a style="color: #ffa500" href="http://www.php.net/set_error_handler">set_error_handler</a>('<span style="color: #8b0000">errorHandler</span>');
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   <a style="color: #0000ff" href="http://www.php.net/function">function</a> errorHandler ($errno, $errstr, $errfile, $errline, $errcontext)
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">{
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">	<span style="color: #008000">//suppress all errors</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">}
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb"></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   <a style="color: #0000ff" href="http://www.php.net/if">if</a> ($_POST['<span style="color: #8b0000">address</span>'] != "<span style="color: #8b0000"></span>") {
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   		doGeo(<a style="color: #ffa500" href="http://www.php.net/urlencode">urlencode</a>($_POST['<span style="color: #8b0000">address</span>']));
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   		}
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   <a style="color: #0000ff" href="http://www.php.net/function">function</a> doGeo($marker) {
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   <span style="color: #008000">// Your Google Maps API key</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   $<a style="color: #ffa500" href="http://www.php.net/key">key</a> = "Your key here";
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb"></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   <span style="color: #008000">// Desired address</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   $address = "<span style="color: #8b0000">http://maps.google.com/maps/geo?q=$marker&#038;output=xml&#038;key=$key</span>";
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff"></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   <span style="color: #008000">// Retrieve the URL contents</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   $page = file_get_contents($address);
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb"></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   <span style="color: #008000">// Parse the returned XML file</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   $xml = new SimpleXMLElement($page);
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff"></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb"><span style="color: #008000">// Retrieve the desired XML node</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff"><span style="color: #008000">//   echo $xml->Response->Placemark->Point->coordinates;</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb"></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   <span style="color: #008000">// Parse the coordinate string</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">   <a style="color: #ffa500" href="http://www.php.net/list">list</a>($longitude, $latitude, $altitude) = <a style="color: #ffa500" href="http://www.php.net/explode">explode</a>("<span style="color: #8b0000">,</span>",
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">        $xml->Response->Placemark->Point->coordinates);
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">   <span style="color: #008000">// Output the coordinates</span>
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">	<a style="color: #0000ff" href="http://www.php.net/echo">echo</a> "<span style="color: #8b0000">

</span>".<a style="color: #ffa500" href="http://www.php.net/urldecode">urldecode</a>($marker)."<span style="color: #8b0000">

</span></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff">

Longitude: $longitude, Latitude: $latitude

"<span style="color: #8b0000">;
</span></pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #fbfbfb">}
</pre>
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; background-color: #ffffff"><span style="color: #0000ff">?></span></pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cyberstarweb.com/2008/04/geocoder-find-your-latitude-and-longitude/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
