<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Thread Pool</title>
	
	<link>http://www.thread-pool.com</link>
	<description>Collection of topics on Software and Hardware Engineering</description>
	<pubDate>Sat, 28 Mar 2009 08:16:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ThreadPool" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Topcoder screen cast</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/TKOuqUiv8sg/</link>
		<comments>http://www.thread-pool.com/2009/03/28/topcoder-screen-cast/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 08:16:49 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[algorithms]]></category>

		<category><![CDATA[topcoder]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=131</guid>
		<description><![CDATA[Ran across the blog of super-topcoder Petr Mitrichev. Especially cool are the screencasts of Petr displaying his mad programming skills in topcoder competitions.
]]></description>
			<content:encoded><![CDATA[<p>Ran across the <a href="http://petr-mitrichev.blogspot.com/">blog</a> of super-topcoder Petr Mitrichev. Especially cool are the <a href="http://petr-mitrichev.blogspot.com/2009/03/tco-r2-and-r3-screencasts.html">screencasts</a> of Petr displaying his mad programming skills in topcoder competitions.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/qKB6k9MBcT4-FY4avMWH8LZl6bg/0/da"><img src="http://feedads.g.doubleclick.net/~a/qKB6k9MBcT4-FY4avMWH8LZl6bg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qKB6k9MBcT4-FY4avMWH8LZl6bg/1/da"><img src="http://feedads.g.doubleclick.net/~a/qKB6k9MBcT4-FY4avMWH8LZl6bg/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/TKOuqUiv8sg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2009/03/28/topcoder-screen-cast/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2009/03/28/topcoder-screen-cast/</feedburner:origLink></item>
		<item>
		<title>The Nolan Bushnell Atari Interview</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/QFsZBmOTcP4/</link>
		<comments>http://www.thread-pool.com/2009/02/28/the-nolan-bushnell-atari-interview/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 06:28:02 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[atari]]></category>

		<category><![CDATA[history]]></category>

		<category><![CDATA[nolan bushnell]]></category>

		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=127</guid>
		<description><![CDATA[Fascinating history of the rise and fall of Atari from its founder: Nolan Bushnell.
Interesting how he talks about Atari in its day being able to attract the best and the brightest. How when everyone in Silicon Valley was going to bare cubes, they went the other way to offices and hot tubs! The way Nolan [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.youtube.com/watch?v=znP8zMCDzxc&amp;feature=related">Fascinating history</a> of the rise and fall of Atari from its founder: Nolan Bushnell.</p>
<p>Interesting how he talks about Atari in its day being able to attract the best and the brightest. How when everyone in Silicon Valley was going to bare cubes, they went the other way to offices and hot tubs! The way Nolan describes the rise of Atari, he could very well be talking about any number of other Sillicon Valley success stories. Since the early 70s so many companies have risen and fallen in the valley, but the core values that make a company succesful have not at all.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/UEn-1CkYJBBLERzPdLSOHWQg8T4/0/da"><img src="http://feedads.g.doubleclick.net/~a/UEn-1CkYJBBLERzPdLSOHWQg8T4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/UEn-1CkYJBBLERzPdLSOHWQg8T4/1/da"><img src="http://feedads.g.doubleclick.net/~a/UEn-1CkYJBBLERzPdLSOHWQg8T4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/QFsZBmOTcP4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2009/02/28/the-nolan-bushnell-atari-interview/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2009/02/28/the-nolan-bushnell-atari-interview/</feedburner:origLink></item>
		<item>
		<title>How to answer Behavioral Interview questions</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/JUJSA2JUCUE/</link>
		<comments>http://www.thread-pool.com/2009/02/15/how-to-answer-behavioral-interview-questions/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 20:52:19 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[interview]]></category>

		<category><![CDATA[jobs]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/2009/02/15/how-to-answer-behavioral-interview-questions/</guid>
		<description><![CDATA[I&#8217;m never sure what is the best way to answer behavioral interview questions. 
I know, I know, there&#8217;s no &#8220;right&#8221; answer. But, clearly the fact that they get asked at all indicates that there are favorable and unfavorable answers.
Recently I read that in politics, politicians are taught that if you get asked a question that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m never sure what is the best way to answer behavioral interview questions. </p>
<p>I know, I know, there&#8217;s no &#8220;right&#8221; answer. But, clearly the fact that they get asked at all indicates that there are favorable and unfavorable answers.</p>
<p>Recently I read that in politics, politicians are taught that if you get asked a question that you don&#8217;t want to answer, then answer the question that you wish you had been asked instead. </p>
<p>This seems to work in politics, do people think that it is a good tactic to answer behavioral interview questions?</p>
<p>To make king concrete let&#8217;s try it out.</p>
<p>Question: what is your biggest weakness.</p>
<p>You wish you were asked: what are your biggest strengths.</p>
<p>Answer: I feel that my biggest strengths are blah&#8230;blah&#8230;blah&#8230; And of course the areas that are outside of my strengths I will work hard on improvng.</p>
<p>What do people think of this answer?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/y4FA4DC1bY0swa9U_vFvF5NhngA/0/da"><img src="http://feedads.g.doubleclick.net/~a/y4FA4DC1bY0swa9U_vFvF5NhngA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/y4FA4DC1bY0swa9U_vFvF5NhngA/1/da"><img src="http://feedads.g.doubleclick.net/~a/y4FA4DC1bY0swa9U_vFvF5NhngA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/JUJSA2JUCUE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2009/02/15/how-to-answer-behavioral-interview-questions/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2009/02/15/how-to-answer-behavioral-interview-questions/</feedburner:origLink></item>
		<item>
		<title>Where are the new jobs?</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/WJ81dvh3Lx8/</link>
		<comments>http://www.thread-pool.com/2009/02/13/where-are-the-new-jobs/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 20:16:18 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=124</guid>
		<description><![CDATA[Interesting blog post by the new york times.
It suggests a flaw in the common wisdom that the only sectors where there are jobs is in education and health-care. While it is true that that&#8217;s where the most job openings are, the fields where the most actual hires are is in business and professional services, which [...]]]></description>
			<content:encoded><![CDATA[<p>Interesting blog post by the <a href="http://economix.blogs.nytimes.com/2009/02/11/where-are-the-job-openings/">new york times</a>.</p>
<p>It suggests a flaw in the common wisdom that the only sectors where there are jobs is in education and health-care. While it is true that that&#8217;s where the most job openings are, the fields where the most actual hires are is in business and professional services, which coincidentally is where most of the layoffs have also occurred.</p>
<p>What I think we see here is a lot of &#8220;rearranging of the deck chairs&#8221; as the new york times puts it. Or in another words, companies replacing workers that they don&#8217;t need anymore with ones that they find more desirable. I think this also highlights a common fallacy that a lot of economists fall for when looking at &#8220;knowledge&#8221; industries. That workers, and their skills, are *not* interchangeable.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/-yPGCkVVE4mrQFJhSbzujjd9KGc/0/da"><img src="http://feedads.g.doubleclick.net/~a/-yPGCkVVE4mrQFJhSbzujjd9KGc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-yPGCkVVE4mrQFJhSbzujjd9KGc/1/da"><img src="http://feedads.g.doubleclick.net/~a/-yPGCkVVE4mrQFJhSbzujjd9KGc/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/WJ81dvh3Lx8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2009/02/13/where-are-the-new-jobs/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2009/02/13/where-are-the-new-jobs/</feedburner:origLink></item>
		<item>
		<title>ASIC digital design blog</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/5BbS_fwpcdo/</link>
		<comments>http://www.thread-pool.com/2009/02/13/asic-digital-design-blog/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 16:04:59 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[ASIC design]]></category>

		<category><![CDATA[chip]]></category>

		<category><![CDATA[VLSI]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=122</guid>
		<description><![CDATA[Ran into this awesome blog on chip design. Best part is the puzzles and challenges which are very fun and educational.
]]></description>
			<content:encoded><![CDATA[<p>Ran into this awesome <a href="http://asicdigitaldesign.wordpress.com/">blog on chip design</a>. Best part is the puzzles and challenges which are very fun and educational.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/R_XrVMMNvYDcBzpARxQpih4ecyU/0/da"><img src="http://feedads.g.doubleclick.net/~a/R_XrVMMNvYDcBzpARxQpih4ecyU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/R_XrVMMNvYDcBzpARxQpih4ecyU/1/da"><img src="http://feedads.g.doubleclick.net/~a/R_XrVMMNvYDcBzpARxQpih4ecyU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/5BbS_fwpcdo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2009/02/13/asic-digital-design-blog/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2009/02/13/asic-digital-design-blog/</feedburner:origLink></item>
		<item>
		<title>Serial entrepreneurs 50% more likely to succeed.</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/EZCqMxDRAiU/</link>
		<comments>http://www.thread-pool.com/2009/02/13/serial-entrepreneurs-nearly-50-more-likely-to-succeed/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 15:10:07 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[entrepreneurs]]></category>

		<category><![CDATA[startups]]></category>

		<category><![CDATA[VC]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=117</guid>
		<description><![CDATA[Great study from HBS which finds that:

34% of successful entrepreneurs are going to be successful in their next startup
23 % of repeat entrepreneurs who failed in their past startup will be successful in their next one
22 % of first time entrepreneurs will be successful.

There&#8217;s no teacher like experience.
And also, this is pretty encouraging, much better [...]]]></description>
			<content:encoded><![CDATA[<p>Great <a title="VC study" href="http://www.pehub.com/31546/hbs-study-concludes-that-vcs-need-successful-serial-entrepreneurs-way-more-than-vice-versa/">study from HBS</a> which finds that:</p>
<ul>
<li>34% of successful entrepreneurs are going to be successful in their next startup</li>
<li>23 % of repeat entrepreneurs who failed in their past startup will be successful in their next one</li>
<li>22 % of first time entrepreneurs will be successful.</li>
</ul>
<p>There&#8217;s no teacher like experience.</p>
<p>And also, this is pretty encouraging, much better than the common wisdom of 1/10 startups will be successful that gets repeated a lot.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/SzEHsSJVJ4nYtXNdeiaDkAm2Cls/0/da"><img src="http://feedads.g.doubleclick.net/~a/SzEHsSJVJ4nYtXNdeiaDkAm2Cls/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/SzEHsSJVJ4nYtXNdeiaDkAm2Cls/1/da"><img src="http://feedads.g.doubleclick.net/~a/SzEHsSJVJ4nYtXNdeiaDkAm2Cls/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/EZCqMxDRAiU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2009/02/13/serial-entrepreneurs-nearly-50-more-likely-to-succeed/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2009/02/13/serial-entrepreneurs-nearly-50-more-likely-to-succeed/</feedburner:origLink></item>
		<item>
		<title>Gitweb installation in 5 minutes</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/TIo9WdurfRQ/</link>
		<comments>http://www.thread-pool.com/2008/11/15/gitweb-installation-in-5-minutes/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 19:35:38 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[git]]></category>

		<category><![CDATA[gitweb]]></category>

		<category><![CDATA[install]]></category>

		<category><![CDATA[newbies]]></category>

		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=110</guid>
		<description><![CDATA[I couldn&#8217;t really find an easy tutorial on getting Gitweb to work on a Mac, so I decided to write one.
The end result should be an interface like the one for the Linux Kernel.
Here are the steps that I used:

Download the Git source. Gitweb comes with it.
Unzip, and cd to the just downloaded source directory.
Copy [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t really find an easy tutorial on getting <a href="http://git.or.cz/gitwiki/Gitweb">Gitweb</a> to work on a Mac, so I decided to write one.</p>
<p>The end result should be an interface like the one for the <a href="http://git.kernel.org/">Linux Kernel</a>.</p>
<p>Here are the steps that I used:</p>
<ol>
<li>Download the <a href="http://git.or.cz/">Git source</a>. Gitweb comes with it.</li>
<li>Unzip, and <strong>cd</strong> to the just downloaded source directory.</li>
<li>Copy the files <strong>gitweb/git-logo.png, gitweb/git-favicon.png, gitweb/gitweb.css </strong>to a directory that your webserver can see. For example, on a Mac, someplace under ~/Sites/, say ~/Sites/gitweb.</li>
<li>Enter:</li>
<p><code><br />
make GITWEB_PROJECTROOT=&#8221;&lt;user dir&gt;/scm&#8221; \<br />
    GITWEB_CSS=&#8221;&lt;user dir&gt;/Sites/gitweb/gitweb.css&#8221; \<br />
    GITWEB_LOGO=&#8221;&lt;user dir&gt;/Sites/gitweb/git-logo.png&#8221; \<br />
    GITWEB_FAVICON=&#8221;&lt;user dir&gt;/Sites/gitweb/git-favicon.png&#8221; \<br />
    bindir=/usr/local/git/bin/ gitweb/gitweb.cgi<br />
</code><br />
Where:<br />
GITWEB_PROJECTROOT :  is the directory that contains your git repository(s)<br />
GITWEB_CSS etc. : is where you copied the files in step 3<br />
bindir : is the directory that contains the git executable.</p>
<li>Copy the newly created gitweb/gitweb.cgi to your cgi script directory, on the Mac the defaulit one is /Library/WebServer/CGI-Executable.</li>
</ol>
<p>Now if you point your browswer to the gitweb.cgi file (e.g. &#8220;http://&lt;host name&gt;/cgi-bin/gitweb.cgi&#8221;), you should see the nice web interface in action.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/XdvDXRwWravMEtM1hwXwMqorC9w/0/da"><img src="http://feedads.g.doubleclick.net/~a/XdvDXRwWravMEtM1hwXwMqorC9w/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/XdvDXRwWravMEtM1hwXwMqorC9w/1/da"><img src="http://feedads.g.doubleclick.net/~a/XdvDXRwWravMEtM1hwXwMqorC9w/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/TIo9WdurfRQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2008/11/15/gitweb-installation-in-5-minutes/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2008/11/15/gitweb-installation-in-5-minutes/</feedburner:origLink></item>
		<item>
		<title>Google Maps Tutorial - Part 2</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/m-O3ASbrGVQ/</link>
		<comments>http://www.thread-pool.com/2008/11/12/google-maps-tutorial-part-2/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 18:29:13 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[google maps api]]></category>

		<category><![CDATA[google maps taxi]]></category>

		<category><![CDATA[google maps tutorial]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=101</guid>
		<description><![CDATA[Next installment of the Google Maps tutorial series.
First we start with the starting point google map implementation, from the last post.
Feel free to peek ahead to the final google map implementation after this interation. Make sure you left click on the map, and drag and drop the resulting markers.
In this iteration I will add map [...]]]></description>
			<content:encoded><![CDATA[<p>Next installment of the Google Maps tutorial series.</p>
<p>First we start with the starting point <a href="http://www.thread-pool.com/taxi1.html">google map implementation</a>, from the last <a href="http://www.thread-pool.com/2008/11/08/google-maps-tutorial-part-1/">post</a>.</p>
<p>Feel free to peek ahead to the <a href="http://www.thread-pool.com/taxi2.html">final google map implementation</a> after this interation. Make sure you left click on the map, and drag and drop the resulting markers.</p>
<p>In this iteration I will add map overlays, actualy two kinds of overlays: markers (GMarker) and lines (GPolyline), that are provided by the Google Maps API.</p>
<p>Also I'll add event handler to handle mouse click events using the GEvent API.</p>
<p>First, I added a function to draw a line and store it in a array called <strong>lines</strong>.<strong> </strong>Drawing lines is as simple as creating a GPolyline object and adding it to the map using the <strong>addOverlay</strong> method.</p>
<div class="igBar"><span id="ljavascript-4"><a href="#" onclick="javascript:showPlainTxt('javascript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-4">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> plotLine<span style="color: #66cc66;">&#40;</span>pt1, pt2<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> polyline = <span style="color: #003366; font-weight: bold;">new</span> GPolyline<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pt1, pt2</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">"#0000ff"</span>, <span style="color: #CC0000;color:#800000;">5</span>, <span style="color: #CC0000;color:#800000;">0</span>.<span style="color: #CC0000;color:#800000;">5</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; map.<span style="color: #006600;">addOverlay</span><span style="color: #66cc66;">&#40;</span>polyline<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; lines.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span>polyline<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Next I added a <strong>plot</strong> function to plot the entire boundary, which is stored in the <strong>boundary</strong> array. In the plot function I first delete all the lines so far, useful if the user changes the boundary by dragging and dropping the markers, and calling the above <strong>plotLine</strong> function with the array of points in the current <strong>boundary</strong> variable.</p>
<p>Note how I can remove existing overlays by invoking the <strong>removeOverlay</strong> method of <strong>map.</strong></p>
<div class="igBar"><span id="ljavascript-5"><a href="#" onclick="javascript:showPlainTxt('javascript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-5">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> plot<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>lines.<span style="color: #006600;">length</span>&gt; <span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> idx <span style="color: #000066; font-weight: bold;">in</span> lines<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006600;">removeOverlay</span><span style="color: #66cc66;">&#40;</span>lines<span style="color: #66cc66;">&#91;</span>idx<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; lines = <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i=<span style="color: #CC0000;color:#800000;">0</span>; i+<span style="color: #CC0000;color:#800000;">1</span>&lt;boundary.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; plotLine<span style="color: #66cc66;">&#40;</span>boundary<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getLatLng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boundary<span style="color: #66cc66;">&#91;</span>i+<span style="color: #CC0000;color:#800000;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getLatLng</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Finally I tie everything together by adding event handlers for a <strong>click</strong> event and a <strong>dragend</strong> event. The click event will place a new marker, which can then be subsequently moved by dragging and dropping it. The Google Maps API comes with a default marker icon when a new marker (GMarker object) is created. This can be overwridden with whatever icon you want by creating a <strong>GIcon</strong> object which I did here for the first placed marker.</p>
<p>Note how the <strong>addListener</strong> method is given a callback function which gets a pointer to the <strong>overlay</strong> and the <strong>point</strong> itself on a click event. The overlay is checked to see whether we clicked on an already existing overlay (if so do nothing), and the point is used to create a GMarker object and add it to the map using <strong>map.addOverlay</strong>.</p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-6">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">GEvent.<span style="color: #006600;">addListener</span><span style="color: #66cc66;">&#40;</span>map, <span style="color: #3366CC;">"click"</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>overlay,point<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>overlay != <span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> n = boundary.<span style="color: #006600;">length</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>first_point<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> func_icon = <span style="color: #003366; font-weight: bold;">new</span> GIcon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; func_icon.<span style="color: #006600;">image</span> = </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">"http://gsacs1.enterprisedemo-google.com/googleMaps/green.png"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; func_icon.<span style="color: #006600;">iconSize</span> = <span style="color: #003366; font-weight: bold;">new</span> GSize<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">26</span>, <span style="color: #CC0000;color:#800000;">26</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; func_icon.<span style="color: #006600;">shadowSize</span> = <span style="color: #003366; font-weight: bold;">new</span> GSize<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">20</span>, <span style="color: #CC0000;color:#800000;">20</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; func_icon.<span style="color: #006600;">iconAnchor</span> = <span style="color: #003366; font-weight: bold;">new</span> GPoint<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">14</span>, <span style="color: #CC0000;color:#800000;">24</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; func_icon.<span style="color: #006600;">infoWindowAnchor</span> = <span style="color: #003366; font-weight: bold;">new</span> GPoint<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">15</span>, <span style="color: #CC0000;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boundary.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GMarker<span style="color: #66cc66;">&#40;</span>point, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>icon: func_icon, draggable: <span style="color: #003366; font-weight: bold;">true</span>, clickable : <span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first_point = <span style="color: #003366; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span>&nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boundary.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GMarker<span style="color: #66cc66;">&#40;</span>point, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>draggable: <span style="color: #003366; font-weight: bold;">true</span>, clickable : <span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006600;">addOverlay</span><span style="color: #66cc66;">&#40;</span>boundary<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; GEvent.<span style="color: #006600;">addListener</span><span style="color: #66cc66;">&#40;</span>boundary<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">"dragend"</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plot<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; plot<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>And that's it, for this iteration. </strong>Check out the <a href="http://www.thread-pool.com/taxi2.html">final product</a>, and stay tuned for the next iteration. Also, you might want to check out the <a href="http://www.thread-pool.com/2008/11/07/google-maps-tutorial-preliminary/">plan for the entire Google Maps Taxi application</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Axyx1gBE86bjJgMoRpT81cT-Hck/0/da"><img src="http://feedads.g.doubleclick.net/~a/Axyx1gBE86bjJgMoRpT81cT-Hck/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Axyx1gBE86bjJgMoRpT81cT-Hck/1/da"><img src="http://feedads.g.doubleclick.net/~a/Axyx1gBE86bjJgMoRpT81cT-Hck/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/m-O3ASbrGVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2008/11/12/google-maps-tutorial-part-2/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2008/11/12/google-maps-tutorial-part-2/</feedburner:origLink></item>
		<item>
		<title>Google Maps Tutorial - Part 1</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/mUVeNnMMEJU/</link>
		<comments>http://www.thread-pool.com/2008/11/08/google-maps-tutorial-part-1/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 16:33:42 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[geocoding]]></category>

		<category><![CDATA[Google maps]]></category>

		<category><![CDATA[google maps tutorial]]></category>

		<category><![CDATA[taxi]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=95</guid>
		<description><![CDATA[As promised part 1 of the Google Maps tutorial. See the original post for the plan for this series of posts.
We are going to build on the code in the original post.
In this part we are going to add a text box that allows the user to enter a street address (e.g. 123 Main street), [...]]]></description>
			<content:encoded><![CDATA[<p>As promised part 1 of the Google Maps tutorial. See the <a href="http://www.thread-pool.com/2008/11/07/google-maps-tutorial-preliminary/">original post</a> for the plan for this series of posts.</p>
<p>We are going to build on the <a href="http://www.thread-pool.com/taxi.html">code in the original post</a>.</p>
<p>In this part we are going to add a text box that allows the user to enter a street address (e.g. 123 Main street), and the map will center on that location.</p>
<p>We have already seen how to center the map using the "<strong>setCenter</strong>" method of the <strong>GMap2</strong> object. Unfortunately "<strong>setCenter</strong>" does not work with a street address, you need to specify the full latitude and longitude coordinates. In order to do the conversion between street address and latitude/longitude, we use the <strong>GClientGeocoder</strong> object that is part of the Google Maps API. </p>
<p>First in the initialize function, which is called when the web page is loaded, we create a <strong>GClientGeocoder</strong> object. </p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-10">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>GBrowserIsCompatible<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; map = <span style="color: #003366; font-weight: bold;">new</span> GMap2<span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"map_canvas"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> center = <span style="color: #003366; font-weight: bold;">new</span> GLatLng<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">37</span>.<span style="color: #CC0000;color:#800000;">4419</span>, -<span style="color: #CC0000;color:#800000;">122</span>.<span style="color: #CC0000;color:#800000;">1419</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006600;">setCenter</span><span style="color: #66cc66;">&#40;</span>center, zoom<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006600;">addControl</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GSmallMapControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; geocoder = <span style="color: #003366; font-weight: bold;">new</span> GClientGeocoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Note also that we added a small map control to the map. This will put a small control on the corner of the map which the user can use to pan and zoom the map.</p>
<p>We create a form so that when the user enters the street address and submits the form, the function findCenter is called and it is passed the argument that the user entered in the text box.</p>
<div class="igBar"><span id="ljavascript-11"><a href="#" onclick="javascript:showPlainTxt('javascript-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-11">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> findCenter<span style="color: #66cc66;">&#40;</span>address<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>geocoder<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; geocoder.<span style="color: #006600;">getLocations</span><span style="color: #66cc66;">&#40;</span>address, findCenterCallback<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
This function issues a query to Google with the street address as an argument. You also specify a callback function, "<strong>findCenterCallback</strong>", which is called by Google when it is done processing the <strong>getLocations</strong> request. </p>
<p>The <strong>findCenterCallback</strong> gets the return response from Google, and the rest of the processing can be done on the client side javascript code.</p>
<div class="igBar"><span id="ljavascript-12"><a href="#" onclick="javascript:showPlainTxt('javascript-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-12">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> findCenterCallback<span style="color: #66cc66;">&#40;</span>response<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!response || response.<span style="color: #000066;">Status</span>.<span style="color: #006600;">code</span> != <span style="color: #CC0000;color:#800000;">200</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"address not found"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; place = response.<span style="color: #006600;">Placemark</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; point = <span style="color: #003366; font-weight: bold;">new</span> GLatLng<span style="color: #66cc66;">&#40;</span>place.<span style="color: #006600;">Point</span>.<span style="color: #006600;">coordinates</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #66cc66;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; place.<span style="color: #006600;">Point</span>.<span style="color: #006600;">coordinates</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006600;">setCenter</span><span style="color: #66cc66;">&#40;</span>point, zoom<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
First the "response" variable is checked to make sure there are no errors.<br />
Then the lattitude and longitude coordinates are extracted from the response, and a new GLatLng object is created. This GLatLng object (point) can then be used to set the map center using the "setCenter" method.</p>
<p>And that's it we are done! You can check out the <a href="http://www.thread-pool.com/taxi1.html">full taxi application demo</a></p>
<p>Stay tuned for next time, when we will work on part 2 of the tutorial.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/KMCE1CFCvE105vZZ6EODkdh4i-w/0/da"><img src="http://feedads.g.doubleclick.net/~a/KMCE1CFCvE105vZZ6EODkdh4i-w/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/KMCE1CFCvE105vZZ6EODkdh4i-w/1/da"><img src="http://feedads.g.doubleclick.net/~a/KMCE1CFCvE105vZZ6EODkdh4i-w/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/mUVeNnMMEJU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2008/11/08/google-maps-tutorial-part-1/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2008/11/08/google-maps-tutorial-part-1/</feedburner:origLink></item>
		<item>
		<title>Monitor Filesystems with Inotify</title>
		<link>http://feedproxy.google.com/~r/ThreadPool/~3/aM-l-IpeO0E/</link>
		<comments>http://www.thread-pool.com/2008/11/07/monitor-filesystems-with-inotify/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 01:16:04 +0000</pubDate>
		<dc:creator>Himadri</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[file system]]></category>

		<category><![CDATA[file system monitoring]]></category>

		<category><![CDATA[inotify]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.thread-pool.com/?p=86</guid>
		<description><![CDATA[I recently had the problem of writing an application that needed to get notifications when changes happened to a particular directory. Specifically, I was writing a Linux kernel mode driver (KMD), which would create entries in the /dev/ file system on connection of various devices, and I needed a user mode program that would detect [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had the problem of writing an application that needed to get notifications when changes happened to a particular directory. Specifically, I was writing a Linux kernel mode driver (KMD), which would create entries in the /dev/ file system on connection of various devices, and I needed a user mode program that would detect these connections.</p>
<p>A collegue pointed me to <a href="http://en.wikipedia.org/wiki/Inotify">Inotify</a>, which solved this problem perfectly. In particular I used the <a href="http://inotify.aiken.cz/?section=inotify-cxx&amp;page=about&amp;lang=en">C++ interface </a>which can be downloaded along with an example code.</p>
<p>You can <a href="http://inotify.aiken.cz/?section=inotify-cxx&amp;page=download&amp;lang=en">download the C++ interface</a> for inotify. This compiles fine with g++ (e.g. g++ -c inotify-cxx.cpp)</p>
<p>And the <a href="http://inotify.aiken.cz/?section=inotify-cxx&amp;page=doc&amp;lang=en">example code for inotify</a> (example.cpp). To use: compile this and link against the inotify-cxx object file.</p>
<p>The example code shows how you can easily get the type of event (e.g. create file, delete file etc.), and the filename of the file.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/vHmtCucH3R6EJoMQvm0EoptQNOA/0/da"><img src="http://feedads.g.doubleclick.net/~a/vHmtCucH3R6EJoMQvm0EoptQNOA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vHmtCucH3R6EJoMQvm0EoptQNOA/1/da"><img src="http://feedads.g.doubleclick.net/~a/vHmtCucH3R6EJoMQvm0EoptQNOA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ThreadPool/~4/aM-l-IpeO0E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thread-pool.com/2008/11/07/monitor-filesystems-with-inotify/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.thread-pool.com/2008/11/07/monitor-filesystems-with-inotify/</feedburner:origLink></item>
	</channel>
</rss>
