<?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>MySandbox &#187; google maps</title>
	<atom:link href="http://sandbox.ronggur.com/tag/google-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandbox.ronggur.com</link>
	<description>Ronggur Hutasuhut Playground</description>
	<lastBuildDate>Thu, 15 Apr 2010 08:53:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google Maps : Pointing and get your marker location</title>
		<link>http://sandbox.ronggur.com/2009/08/01/google-maps-pointing-and-get-your-marker-location/</link>
		<comments>http://sandbox.ronggur.com/2009/08/01/google-maps-pointing-and-get-your-marker-location/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 11:13:44 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery tutorial]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=102</guid>
		<description><![CDATA[ In this post i want to try give some simple script to get your marker location in google maps. Next we will ceate one marker and when you  drag and drop it, you'll get the position of the marker ( latitude and langitude ). You can use this kind of script if you want to add google maps feature in to your websites and want to point position and save it in to your database



Related posts:<ol><li><a href='http://sandbox.ronggur.com/2009/11/26/new-google-searc-interface/' rel='bookmark' title='Permanent Link: New Google search interface'>New Google search interface</a> <small>Have you tried the new google search intrerface? here i...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="pageTracker._trackPageview('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>In this post i want to try give some simple script to get your marker location in google maps. Next we will ceate one marker and when you  drag and drop it, you&#8217;ll get the position of the marker ( latitude and langitude ). You can use this kind of script if you want to add google maps feature in to your websites and want to point position and save it in to your database</p>
<div id="attachment_111" class="wp-caption aligncenter" style="width: 310px"><a href="http://sandbox.ronggur.com/wp-content/uploads/2009/08/image.jpg"><img class="size-medium wp-image-111" title="image" src="http://sandbox.ronggur.com/wp-content/uploads/2009/08/image-300x141.jpg" alt="Image Preview" width="300" height="141" /></a><p class="wp-caption-text">Image Preview</p></div>
<p>As usual we&#8217;ll use  jQuery to give some little help. Lets start</p>
<h4 style="text-align: left;"><strong>1. HTML &amp; PHP files</strong></h4>
<p>You can copy html below. Make sure you already have key for your google maps and use your own key <img src='http://sandbox.ronggur.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . And also don&#8217;t forget to include <a title="jquery" href="http://jquery.com" onclick="pageTracker._trackPageview('/outgoing/jquery.com?referer=');">jQuery</a> library.</p>
<p>To get the current position of the marker, we will use hidden intput to store the position temporary before we post it to php file.</p>
<pre class="brush: xml;">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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=iso-8859-1&quot; /&gt;
&lt;title&gt;Google Map in Learning&lt;/title&gt;
&lt;link href=&quot;styles/style.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; /&gt;
&lt;script src=&quot;js/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;v=2&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;sensor=false&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;key=ABQIAAAAYeuJd8iDXzlrlsewUFBcLhQCLRJBQIjl4T4yd7P58JjfH0ny1BRyKA-JaUsGkxqxnC7LUYx0xI7rAQ&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/addmarker.js&quot;  type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;wrapper_map&quot;&gt;
&lt;div id=&quot;map_canvas&quot; style=&quot;width: 640px; height: 300px&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;wrapper_form&quot;&gt;
&lt;p&gt;&lt;strong&gt;Your Location : &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Latitude : &lt;span id=&quot;sLat&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Longitude : &lt;span id=&quot;sLng&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;form name=&quot;fLocation&quot; id=&quot;fLocation&quot; method=&quot;post&quot; action=&quot;post.php&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;lat&quot; id=&quot;lat&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;lng&quot; id=&quot;lng&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Save&quot; /&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Next is one line php script and named it &#8216;post.php&#8217;, this script just to show that your post data from html is work.</p>
<pre class="brush: php;">

var_dump($_POST);
</pre>
<p><span id="more-102"></span></p>
<h4 style="text-align: left;"><strong>2. JavaScript</strong></h4>
<p>Lets create addmarker.js. Here is the code, i put some comment above the line</p>
<pre class="brush: jscript;">

$(document).ready(function() {
$(&quot;#wrapper_map&quot;).width($(&quot;#map_canvas&quot;).width());
// initialize default lat &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; lang in this case i set to Indonesia

var indLat = -2;
var indLng = 120;

// setup default position into text and hidden input

$(&quot;#sLat&quot;).text(indLat);
$(&quot;#sLng&quot;).text(indLng);
$(&quot;#lat&quot;).val(indLat);
$(&quot;#lng&quot;).val(indLng);

// start setup google maps

var map = new GMap2(document.getElementById(&quot;map_canvas&quot;));
var center = new GLatLng(indLat, indLng);
map.setCenter(center, 4);
map.setUIToDefault();

var marker = new GMarker(center, { draggable: true });

GEvent.addListener(marker, &quot;dragstart&quot;, function() {
map.closeInfoWindow();
});

// a listener to get current position and store it to hidden input in html

GEvent.addListener(marker, &quot;dragend&quot;, function() {
// latitude
$(&quot;#sLat&quot;).text(roundNumber(getObjectLoc(marker, 'lat'), 5));
// store it temporary in hidden input (lat)
$(&quot;#lat&quot;).val(getObjectLoc(marker, 'lat'));
// longitude
$(&quot;#sLng&quot;).text(roundNumber(getObjectLoc(marker, 'lang'), 5));
// store it temporary in hidden input (lng)
$(&quot;#lng&quot;).val(getObjectLoc(marker, 'lang'));
});

// adding marker
map.addOverlay(marker);
// end setup google maps

// fungction to get the marker posistion

getObjectLoc = function(object, type){
var objectLoc = '';
if(type=='lat'){
objectLoc = object.getLatLng().lat();
}else{
objectLoc = object.getLatLng().lng();
}

return objectLoc;
}

// just round your position if you think it is too long to show

roundNumber = function(rnum, rlength) {
newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
return newnumber;
}
});
</pre>
<p>That&#8217;s all. So when you press &#8216;Save&#8217; button it should print out your current marker position.</p>
<p><strong>- <a title="Simple star rating" href="http://dock.ronggur.com/tutorial/pointingmarker/" onclick="pageTracker._trackPageview('/outgoing/dock.ronggur.com/tutorial/pointingmarker/?referer=');">View Demo</a></strong></p>
<p><strong>- Download file <a class="downloadlink" href="http://sandbox.ronggur.com/wp-content/plugins/download-monitor/download.php?id=6" title=" downloaded 100 times" >Google Maps : Pointing and get your marker location (100)</a></strong></p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="ronggur.mh@gmail.com" /><input type="hidden" name="return" value="Thank you for your kindness :D" /><input type="hidden" name="item_name" value="Buy Me a Beer for Google Maps : Pointing and get your marker location" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://sandbox.ronggur.com/wp-content/plugins/buy-me-beer/icon_cafe.gif" align="left" alt="coffee" title="coffee" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=ronggur.mh@gmail.com&amp;currency_code=USD&amp;amount=&amp;return=Thank you for your kindness :D&amp;item_name=Buy+Me+a+Beer+for+Google+Maps+:+Pointing+and+get+your+marker+location" target="paypal" onclick="pageTracker._trackPageview('/outgoing/www.paypal.com/cgi-bin/webscr?cmd=_xclick_amp_business=ronggur.mh_gmail.com_amp_currency_code=USD_amp_amount=_amp_return=Thank_you_for_your_kindness_D_amp_item_name=Buy+Me+a+Beer+for+Google+Maps+_+Pointing+and+get+your+marker+location&amp;referer=');">You can give me some coffee if you want to :D</a></p><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="pageTracker._trackPageview('/outgoing/blinklist.com/index.php?Action=Blink/addblink.php_amp_Name=Google+Maps+_3A+Pointing+and+get+your+marker+location_amp_Description=Google+Maps+_3A+Pointing+and+get+your+marker+location_amp_Url=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=Google+Maps+%3A+Pointing+and+get+your+marker+location&amp;Description=Google+Maps+%3A+Pointing+and+get+your+marker+location&amp;Url=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/www.bloglines.com/sub/http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F?referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F" rel="nofollow" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/del.icio.us/post?url=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F_amp_title=Google+Maps+_3A+Pointing+and+get+your+marker+location&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F&amp;title=Google+Maps+%3A+Pointing+and+get+your+marker+location" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/digg.com/submit?phase=2_amp_url=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F_amp_title=Google+Maps+_3A+Pointing+and+get+your+marker+location&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F&amp;title=Google+Maps+%3A+Pointing+and+get+your+marker+location" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/www.facebook.com/sharer.php?u=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/www.google.com/bookmarks/mark?op=edit_amp_output=popup_amp_bkmk=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F_amp_title=Google+Maps+_3A+Pointing+and+get+your+marker+location&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F&amp;title=Google+Maps+%3A+Pointing+and+get+your+marker+location" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/www.stumbleupon.com/submit?url=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F_amp_title=Google+Maps+_3A+Pointing+and+get+your+marker+location&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F&amp;title=Google+Maps+%3A+Pointing+and+get+your+marker+location" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/www.technorati.com/faves?add=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="pageTracker._trackPageview('/outgoing/myweb2.search.yahoo.com/myresults/bookmarklet?u=http_3A_2F_2Fsandbox.ronggur.com_2F2009_2F08_2F01_2Fgoogle-maps-pointing-and-get-your-marker-location_2F_amp_t=Google+Maps+_3A+Pointing+and+get+your+marker+location&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsandbox.ronggur.com%2F2009%2F08%2F01%2Fgoogle-maps-pointing-and-get-your-marker-location%2F&amp;t=Google+Maps+%3A+Pointing+and+get+your+marker+location" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sandbox.ronggur.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://sandbox.ronggur.com/2009/11/26/new-google-searc-interface/' rel='bookmark' title='Permanent Link: New Google search interface'>New Google search interface</a> <small>Have you tried the new google search intrerface? here i...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="pageTracker._trackPageview('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2009/08/01/google-maps-pointing-and-get-your-marker-location/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
