<?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>AddyOsmani.com &#124; Where Web Businesses Grow &#187; google maps plugin</title>
	<atom:link href="http://addyosmani.com/blog/tag/google-maps-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://addyosmani.com/blog</link>
	<description>This is the home of Addy Osmani (Web Developer, Designer &#38; Author). Here you can find some great tips and tutorials on everything to do with web development and even a few useful code samples!</description>
	<lastBuildDate>Sun, 25 Jul 2010 14:41:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to easily add a Google Map using jQuery and an address in less than 5 minutes</title>
		<link>http://addyosmani.com/blog/how-to-easily-add-a-google-map-using-jquery-and-an-address-in-less-than-5-minutes/</link>
		<comments>http://addyosmani.com/blog/how-to-easily-add-a-google-map-using-jquery-and-an-address-in-less-than-5-minutes/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 19:39:53 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[API Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[add map]]></category>
		<category><![CDATA[add maps]]></category>
		<category><![CDATA[easy google maps]]></category>
		<category><![CDATA[easy maps]]></category>
		<category><![CDATA[embed map]]></category>
		<category><![CDATA[embed maps]]></category>
		<category><![CDATA[google api tutorial]]></category>
		<category><![CDATA[google map tutorial]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[google maps api tutorial]]></category>
		<category><![CDATA[google maps plugin]]></category>
		<category><![CDATA[google maps tutorial]]></category>
		<category><![CDATA[include map]]></category>
		<category><![CDATA[include map in my page]]></category>
		<category><![CDATA[integrate javascript map]]></category>
		<category><![CDATA[javascript google maps]]></category>
		<category><![CDATA[javascript map]]></category>
		<category><![CDATA[jquery google maps]]></category>
		<category><![CDATA[jquery maps in my page]]></category>
		<category><![CDATA[jquery maps plugin]]></category>
		<category><![CDATA[jquery maps tutorial]]></category>
		<category><![CDATA[maps]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/how-to-easily-add-a-google-map-using-jquery-and-an-address-in-less-than-5-minutes/</guid>
		<description><![CDATA[&#160; Hi guys. Today I thought we’d take a look at how to easily add Google Maps to your pages. Many of the examples I’ve seen online for how to use the Maps service rely on you being able to get the exact longitude and latitude of your location for the API to figure out [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2009/09/jmaps.jpg" class="thickbox"><img title="jmaps" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="288" alt="jmaps" src="http://addyosmani.com/blog/wp-content/uploads/2009/09/jmaps_thumb.jpg" width="391" border="0" /></a> </p>
<p>Hi guys. Today I thought we’d take a look at how to easily add Google Maps to your pages. Many of the examples I’ve seen online for how to use the Maps service rely on you being able to get the exact <a href="http://www.kayakhelp.com/basic-kayaking-skills/latitude-and-longitude-explained.php">longitude and latitude</a> of your location for the API to figure out where the location you want to show is displayed. I think that this is a little too demanding for any business (or developer) to easily lookup and so I thought I’d share with you a much easier way of getting Maps on your site (whether you want to highlight one location or many)&#8230;and all you&#8217;ll need is the addresses! </p>
<p> <span id="more-105"></span>
<p>&#160;</p>
<p>What we’re going to be using for our example is David Hong’s excellent new jQuery Google Maps plugin to create <a href="http://www.addyosmani.com/resources/googlemaps/maps.html">this demo</a>. The best part of the plugin is that it supports you just providing an address or list of addresses to the locations you want to show..and it’ll show you a map with all of them on it. </p>
<p>&#160;</p>
<p>For example: </p>
<p><font face="Courier" color="#804000" size="2">var addr = [&quot;10 Downing Street Westminster, London, SW1A 2AA, United Kingdom &quot;]</font></p>
<p>&#160;</p>
<p>Pretty cool, right?. So, lets have a little tutorial session.</p>
<p>&#160;</p>
<p>The first thing I’d like you to do is signup for a Google Maps API key before we get started. You can do this <a href="http://code.google.com/apis/maps/signup.html">here</a>.&#160;&#160; Next, <a href="http://www.addyosmani.com/resources/googlemaps/maps.rar"><strong>download</strong></a> my tutorial pack for this post and open up maps.html in your favourite text editor.</p>
<p>&#160;</p>
<p>All you need to do is find the following line and paste your API key over the text in bold, then save.</p>
<p>&#160;</p>
<p><font face="Courier" size="2">&lt;script type=&quot;text/javascript&quot; src=</font><a href="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false&amp;amp;key="><font face="Courier" size="2">http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false&amp;amp;key=</font></a><font size="2"><font face="Courier"><strong><font color="#503112">API_KEY_GOES_HERE</font></strong>&gt;&lt;/script&gt;</font></font></p>
<p>&#160;</p>
<p>We then include David’s jQuery plugin as well as a copy of jQuery itself. The complete list of includes for the page should then be as follows:</p>
<p>&#160;</p>
<p><font face="Courier" color="#804000" size="2">&lt;script type=&quot;text/javascript&quot; src=&quot;</font><a href="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js&quot;"><font face="Courier" color="#804000" size="2">http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js&quot;</font></a><font face="Courier" color="#804000" size="2">&gt;&lt;/script&gt;</font></p>
<p><font face="Courier" color="#804000" size="2">&lt;script type=&quot;text/javascript&quot; src=&quot;</font><a href="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false&amp;amp;key=YOUR_API_KEY"><font size="2"><font face="Courier"><font color="#804000">http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false&amp;amp;key=<strong>YOUR_API_KEY</strong></font></font></font></a><font face="Courier" color="#804000" size="2">&quot;&gt;&lt;/script&gt;      <br />&lt;script type=&quot;text/javascript&quot; src=&quot;jquerymaps.js&quot;&gt;&lt;/script&gt;</font></p>
<p>&#160;</p>
<p>&#160;</p>
<p>If you scroll down the page you’ll see a JavaScript array that looks a lot like the address sample I noted above. Let’s try to render a map that shows us a few of the important landmarks over in London. </p>
<p>&#160;</p>
<p><font face="Courier" color="#804000" size="2">var addr = [</font></p>
<p><font face="Courier" color="#804000" size="2">“10 Downing Street Westminster, London, SW1A 2AA, United Kingdom”, “Buckingham Palace, London, SW1A 1AA, UK”, </font></p>
<p><font face="Courier" color="#804000" size="2">“Big Ben, Bridge St, London, Westminster,SW1A 2, United Kingdom”];</font></p>
<p><font face="Courier" color="#804000" size="2"></font></p>
<p>Next, lets create and initiate our map. For this we define a new div element to hold our map (lets call it google maps to keep it simple):</p>
<p>&#160;</p>
<p><font face="Courier" color="#804000" size="2">&lt;div id=&quot;google-map&quot; class=&quot;canvas&quot;&gt;&lt;/a&gt;</font></p>
<p>&#160;</p>
<p>And finally our last step is attach a map to this div which we can do as follows (note that you can also easily set the map zoom and configure whether or not to use labels in your final map).</p>
<p>&#160;</p>
<p><font face="Courier" color="#804000" size="2">$(function() {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(&quot;div#google-map&quot;).googlemap({       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; controls: true,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; labels: true,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; zoom: 4,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; addresses: a,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; debug: true       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })</font></p>
<p>&#160;</p>
<p>Thats it!. I hope this tutorial helps you to easily integrate Google Maps into your websites, projects and blogs. Please feel free to Retweet if you liked it.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/how-to-easily-add-a-google-map-using-jquery-and-an-address-in-less-than-5-minutes/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
	</channel>
</rss>
