<?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>Subesh Pokhrel&#039;s Blog - Magento Development Tips &#187; longitude</title>
	<atom:link href="http://subesh.com.np/tag/longitude/feed/" rel="self" type="application/rss+xml" />
	<link>http://subesh.com.np</link>
	<description>PHP &#38; Magento Tips and Tutorials</description>
	<lastBuildDate>Tue, 20 Mar 2012 18:15:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get Latitude and Longitude Of User From Simple Javascript!</title>
		<link>http://subesh.com.np/2009/07/get-latitude-and-longitude-of-user-from-simple-javascript/</link>
		<comments>http://subesh.com.np/2009/07/get-latitude-and-longitude-of-user-from-simple-javascript/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 04:04:01 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=77</guid>
		<description><![CDATA[I am a big fan of Latitude and Longitude, as you all might know, I have other post related to Latitude and Longitude and Google Maps. I came across one of the greatest feature of Mozilla Firefox 3.5, and that was to get the latitude and Longitude of user using simple Javascript. No API to [...]]]></description>
			<content:encoded><![CDATA[<p>I am a big fan of Latitude and Longitude, as you all might know, I have other post related to Latitude and Longitude and Google Maps.<br />
I came across one of the greatest feature of Mozilla Firefox 3.5, and that was to get the latitude and Longitude of user using simple Javascript. No API to use, No query to Google or anything. Here&#8217;s the code.</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script&gt;
if (navigator.geolocation) {
 var watchID = navigator.geolocation.watchPosition(function(position) {
  do_something(position.coords.latitude, position.coords.longitude);
}
);
} else {
  alert(&quot;I'm sorry, but geolocation services are not supported by your browser.&quot;);
}

function do_something(lat,long){
alert(lat);
alert(long);
}
&lt;/script&gt;
</pre>
<p>Remember this only works on Mozilla Firefox 3.5. I&#8217;ll later come up with using this method to plot user on Google Maps, So follow on !</p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2009/07/get-latitude-and-longitude-of-user-from-simple-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tabbed Infowindow in Google Maps</title>
		<link>http://subesh.com.np/2008/07/tabbed-infowindow-in-google-maps/</link>
		<comments>http://subesh.com.np/2008/07/tabbed-infowindow-in-google-maps/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 12:27:00 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=64</guid>
		<description><![CDATA[I wanted to show different categories of information on one GMarker. That is I wanted to show different types of information on a Infowindow for a point on Google Maps. For that I used a tabbed info window, which helped me to show different data on each tabs. Here is the code of what I [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to show different categories of information on one GMarker. That is I wanted to show different types of information on a Infowindow for a point on Google Maps. For that I used a tabbed info window, which helped me to show different data on each tabs. Here is the code of what I have done. I have shown the latitude and longitude of a placed clicked on the map on the tabbed info window. This is just the script part. The demo and download links are given below.</p>
<pre class="brush: jscript; title: ; notranslate">
 &lt;script type=&quot;text/javascript&quot;&gt;
     var iconBlue = new GIcon();
    iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(26.88157422515243, 86.30859375);
    function load() {
		  if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById(&quot;map&quot;));
			map.setCenter(point,3);
			GEvent.addListener(map, 'click', function(overlay, point) {
			  var lati=point.lat();
			  var long=point.lng();
			  var marker= new GMarker(new GLatLng(lati, long),{draggable: false});
			  map.addOverlay(marker);
				  var infoTabs = [	new GInfoWindowTab(&quot;Lat-Tab&quot;, &quot;&lt;h1&gt; Latitude:&lt;/h1&gt;&lt;br /&gt;&quot;+lati),	new GInfoWindowTab(&quot;Long-Tab&quot;, &quot;&lt;h1&gt;Longitude&lt;/h1&gt;&lt;br /&gt;&quot;+long)];
			  marker.openInfoWindowTabsHtml(infoTabs);
			 });
		}
	}
  &lt;/script&gt;
</pre>
<p>Lets focus on the <strong>#17-#26</strong> Lines of codes. Other Lines are already described on other posts. Please see the related post link below the post.<br />
<strong>#17:</strong> Creates a GMarker on the point where clicked on the Map.<br />
<strong>#18:</strong> Addes the GMarker over the Map.<br />
<strong>#19:</strong> Initiates an array of tabs<strong>infoTabs </strong> with <strong>GInfoWindowTab </strong> function with <strong>tabname</strong> and its <strong>innerHTML</strong> as parameters.<br />
<strong>#20:</strong> Opens the infowindow calling <strong>openInfoWindowTabsHtml</strong> function and the array of tabs as parameters.</p>
<p><a href="http://subeshexamples.googlecode.com/files/tabinfo.html"><strong>[Download]</strong></a> <a href="http://subesh.com.np/demo/tabinfo.html"><strong>[Demo]</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2008/07/tabbed-infowindow-in-google-maps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping The IP Address to Latitude and Longitude In Google Maps</title>
		<link>http://subesh.com.np/2008/07/mapping-the-ip-address-to-latitude-and-longitude-in-google-maps/</link>
		<comments>http://subesh.com.np/2008/07/mapping-the-ip-address-to-latitude-and-longitude-in-google-maps/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 13:03:32 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=63</guid>
		<description><![CDATA[At last I found hostip.info provides a service for getting the latitude and longitude of a place on the basis of the user&#8217;s ip address. Its light weight and free, rather than downloading bulky database and getting paid services, for getting latitude and longitude on the basis of IP. Here is the simplest way to [...]]]></description>
			<content:encoded><![CDATA[<p>At last I found <strong>hostip.info</strong> provides a service for getting the latitude and longitude of a place on the basis of the user&#8217;s ip address. Its light weight and free, rather than downloading bulky database and getting paid services, for getting <strong>latitude and longitude</strong> on the basis of IP.<br />
Here is the simplest way to do it. Requested to<strong> http://api.hostip.info/?ip=$ip&#038;position=true</strong> it responds XML formatted output. So we need to parse XML code using DOM class of PHP.<strong>(#19-#23)</strong>. Remember, the <strong>position=true</strong> should be set to get the latitude and longitude otherwise it will not show on default.<br />
<!--readmore--><br />
Here is the code and I will soon upload the working demo.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*
Subesh Pokhrel
subesh.com.np
Get the code for Real IP of the site from roshanbh.com.np
Mapping The IP Address to Latitude and Longitude.
*/
function IPtoLatLng($ip)
{
	$latlngValue=array();
	$dom = new DOMDocument();
	$ipcheck = ip2long($ip);

    if($ipcheck == -1 || $ipcheck === false){
		echo &quot;ERROR: INVALID IP&quot;;
		exit;
	}
	else
		$uri = &quot;http://api.hostip.info/?ip=$ip&amp;position=true&quot;;
 	$dom-&gt;load($uri);
	$name=$dom-&gt;getElementsByTagNameNS('http://www.opengis.net/gml','name')-&gt;item(1)-&gt;nodeValue;
	$coordinates=$dom-&gt;getElementsByTagNameNS('http://www.opengis.net/gml','coordinates')-&gt;item(0)-&gt;nodeValue;
	$temp=explode(&quot;,&quot;,$coordinates);
	$latlngValue['LNG']=$temp[0];
	$latlngValue['LAT']=$temp[1];
	$latlngValue['NAME']=$name;
	return $latlngValue;

}
//calling the functions and setting on array $latlng
$IP=getRealIpAddr(); //from roshanbh.com.np
$latlng=IPtoLatLng($IP);
?&gt;
</pre>
<p><strong>[UPDATE] <a href="http://subeshexamples.googlecode.com/files/ip.php">[DOWNLOAD]</a></strong><br />
Due to high request of the visitors I have posted the whole source code here.. just copy the PHP part above anywhere the script part and get the IP code from http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html and run. Remember you need PHP5, because the DOM used is of PHP5.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
  &lt;head&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
    &lt;title&gt;Google Maps Plotting  User By Refrence Of IP Address | Subesh.com.np&lt;/title&gt;

 &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAAPHLcOOGHX2-uLk3K8q1nMRSFS3Iba-Yq79Uuy07kI14Q-o9MOhQTADZYj-oIAYvmRBVx8i9NqeBSjg&quot;
      type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    //&lt;![CDATA[

    var iconBlue = new GIcon();
    iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

	var point = new GLatLng(parseFloat('&lt;?=$latlng['LAT']?&gt;'),parseFloat('&lt;?=$latlng['LNG']?&gt;'));

		function load() {
		  if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById(&quot;map&quot;));
			map.setCenter(new GLatLng(parseFloat('&lt;?=$latlng['LAT']?&gt;'),parseFloat('&lt;?=$latlng['LNG']?&gt;')),3);
			var marker = createMarker(point);
            map.addOverlay(marker);
		}
	}

	 function createMarker(point) {
      var marker = new GMarker(point, iconBlue);
      var html = &quot;&lt;h1&gt;Gothcha! HA HA &lt;/h1&gt; &lt;br /&gt;You Are Here !&lt;br /&gt;&lt;b&gt;&lt;?=$latlng['NAME']?&gt;&lt;/b&gt; &quot;;
      GEvent.addListener(marker, 'mouseover', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
 //]]&gt;

  &lt;/script&gt;
 &lt;/head&gt;
  &lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot;&gt;
  &lt;h1&gt;Subesh.com.np: Maps Example&lt;/h1&gt;
   &lt;div id=&quot;map&quot; style=&quot;width: 500px; height: 300px&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2008/07/mapping-the-ip-address-to-latitude-and-longitude-in-google-maps/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Latitude and Longitude Of a Place in Google Maps Using Zip Code</title>
		<link>http://subesh.com.np/2008/06/latitude-and-longitude-of-a-place-in-google-maps-using-zip-code/</link>
		<comments>http://subesh.com.np/2008/06/latitude-and-longitude-of-a-place-in-google-maps-using-zip-code/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 17:07:31 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>
		<category><![CDATA[zip code]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=29</guid>
		<description><![CDATA[I have already posted similar post for finding out the latitude and longitude of a place using Google maps, but when I studied the traffic details and found out that when people visit that post, they sometime come with keywords like zipcode+latitude and longitudes, so I thought it would be better to them to post [...]]]></description>
			<content:encoded><![CDATA[<p>I have already posted similar post for finding out the latitude and longitude of a place using Google maps, but when I studied the traffic details and found out that when people visit that post, they sometime come with keywords like <strong>zipcode+latitude and longitudes</strong>, so I thought it would be better to them to post another article, giving them what they exactly want.</p>
<p>Before I write down the codes there is something we should know. Google provides a service of returning <strong>CSV</strong> (Comma Seperated Values) when requested to <em><strong>http://maps.google.com/maps/geo?q=$query&#038;output=csv&#038;key=$key</strong></em>. The <strong>$query</strong> may contain <strong>address, zip code, city and country</strong>. The service also outputs in other formats. But we have choosed CSV format because it would be easy for us to explode the values separated by commas. The output type is defined by the <strong><em>output</em> </strong>parameter in the URL. The output or response we then receive are in the format of <strong><em>geocode, accuracy, latitude, longitude</em></strong>.  <strong>$key</strong> is the  Google maps API key.</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
class googleRequest {

  var $gKey;
  var $code;
  var $Accuracy;
  var $latitude;
  var $longitude;
  var $address;
  var $city;
  var $country;
  var $error;

  function GetRequest() {

    if (strlen($this-&gt;gKey) &gt; 1) {
      $q = str_replace(' ', '_', $this-&gt;address.','.$this-&gt;zip.'+'.$this-&gt;city.','.$this-&gt;country);
      if ($d = @fopen(&quot;http://maps.google.com/maps/geo?q=$q&amp;output=csv&amp;key=&quot;.$this-&gt;gKey, &quot;r&quot;)) {
        $gcsv = @fread($d, 30000);
        @fclose($d);

       $output=array();
       $tmp = explode(&quot;,&quot;, $gcsv);

       // $this-&gt;code      = $tmp[0];
       // $this-&gt;Accuracy  = $tmp[1];
        $output[0]=$this-&gt;latitude  = $tmp[2];
        $output[1]=$this-&gt;longitude = $tmp[3];
        return $output;

      } else {
        $error = &quot;NO_CONNECTION&quot; ;
      }
    } else {
      $error = &quot;No Google Maps Api Key&quot; ;
    }
  }

}

?&gt;
</pre>
<p>The above class can be implemented as following.</p>
<pre class="brush: php; title: ; notranslate">
$obj_google=new googleRequest;
$obj_google-&gt;zip=35005;

/* alternate uses
$obj_google-&gt;country=&quot;Country Name Here&quot;;
$obj_google-&gt;city=&quot;City Name Here&quot;;
$obj_google-&gt;address=&quot;address&quot;;
*/
$obj_google-&gt;gKey=&quot;ABQIAAAAPHLcOOGHX2-uLk3K8q1nMRTkUAbhgKwL1jWWfpv-KGJeCrct7hTsLLnZdnZjzehmRIkaePagQvKNbw&quot;;
$latlng=$obj_google-&gt;GetRequest();
var_dump($latlng);
</pre>
<p>The above returns latitude and longitude of place with zip code<strong> 35005</strong> as <strong>array(2) { [0]=>  string(9) &#8220;33.592857&#8243; [1]=>  string(10) &#8220;-86.994015&#8243; }</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2008/06/latitude-and-longitude-of-a-place-in-google-maps-using-zip-code/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How To Get Latitude and Longitude of a Place Using Google Maps</title>
		<link>http://subesh.com.np/2008/05/how-to-get-latitude-and-longitude-of-a-place-using-google-maps/</link>
		<comments>http://subesh.com.np/2008/05/how-to-get-latitude-and-longitude-of-a-place-using-google-maps/#comments</comments>
		<pubDate>Tue, 20 May 2008 05:03:23 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[gmarker]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=19</guid>
		<description><![CDATA[I was so frustrated during one project where I need to find out the geological latitude and longitude of the place, with the help of Google Maps. So I googled a lot and came up with a function function (overlay,point).On calling this function on mouse click event the latitude and longitude are returned as point.lat() [...]]]></description>
			<content:encoded><![CDATA[<p>I was so frustrated during one project where I need to find out the geological latitude and longitude of the place, with the help of Google Maps. So I googled a lot and came up with a function function (overlay,point).On calling this function on mouse click event the latitude and longitude are returned as <strong><em>point.lat()</em></strong> for latitude and <em><strong>point.lng()</strong></em> for longitude. This is the source code just the javascript part.<br />
<a href="http://subesh.com.np/demo/tabinfo.html"><strong>[UPDATE DEMO]</strong></a></p>
<pre class="brush: jscript; title: ; notranslate">
  &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAAPHLcOOGHX2-uLk3K8q1nMRTkUAbhgKwL1jWWfpv-KGJeCrct7hTsLLnZdnZjzehmRIkaePagQvKNbw&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
    //&lt;![CDATA[

    var map = new GMap2(document.getElementById(&quot;map&quot;));
    map.setCenter(new GLatLng(37.4419, -122.1419), 4);

	var marker = new GMarker(new GLatLng(37.4419, -122.1419), {draggable: false});
	map.addOverlay(marker);
	GEvent.addListener(map, 'click', function(overlay, point) {
		  var lati=point.lat();
		  var long=point.lng();
		  var marker= new GMarker(new GLatLng(lati, long),{draggable: false});
		  map.addOverlay(marker);
		  marker.openInfoWindowHtml(&quot;Latitude:&quot;+lati+&quot;&lt;br /&gt;&quot;+&quot;Longitude:&quot;+long);
		 });

	//]]&gt;
    &lt;/script&gt;
</pre>
<p>What I have done here is I have displayed the latitude and longitude on a information window of a GMarker. GMarker represents a point on the map. I may put something about GMarker later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2008/05/how-to-get-latitude-and-longitude-of-a-place-using-google-maps/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

