<?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>My stuff &#187; Google maps</title>
	<atom:link href="http://michelhollands.net/blog/index.php/category/google-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://michelhollands.net/blog</link>
	<description>Tech and travel tidbits</description>
	<lastBuildDate>Tue, 13 Dec 2011 09:59:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Trip maps page</title>
		<link>http://michelhollands.net/blog/2009/01/06/trip-maps-page/</link>
		<comments>http://michelhollands.net/blog/2009/01/06/trip-maps-page/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 14:21:53 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Google maps]]></category>

		<guid isPermaLink="false">http://michelhollands.net/blog/2009/01/06/trip-maps-page/</guid>
		<description><![CDATA[Hello, best wishes for the new year first of all. A new page for trip maps was added, showing the Google Maps I&#8217;ve created to show photos. Pretty soon all cameras will have GPS, so this type of map will be generated automatically.]]></description>
			<content:encoded><![CDATA[<p>Hello, best wishes for the new year first of all.</p>
<p>A new page for <a href="http://michelhollands.net/blog/trip-maps/">trip maps</a> was added, showing the Google Maps I&#8217;ve created to show photos. Pretty soon all cameras will have GPS, so this type of map will be generated automatically. </p>
]]></content:encoded>
			<wfw:commentRss>http://michelhollands.net/blog/2009/01/06/trip-maps-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Google maps stuff</title>
		<link>http://michelhollands.net/blog/2007/06/26/more-google-maps-stuff/</link>
		<comments>http://michelhollands.net/blog/2007/06/26/more-google-maps-stuff/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 14:50:27 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Google maps]]></category>
		<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://michelhollands.net/blog/2007/06/26/more-google-maps-stuff/</guid>
		<description><![CDATA[This Google Maps API Tutorial website has some very good how-tos on Google Maps. Needless to say, I added some of those things like Fitting the map to the data and Lots of sidebar entries to my maps. Check out the New Zealand and Firenze maps.]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://www.econym.demon.co.uk/googlemaps/index.htm">Google Maps API Tutorial</a> website has some very good how-tos on Google Maps.</p>
<p>Needless to say, I added some of those things like <a href="http://www.econym.demon.co.uk/googlemaps/basic14.htm">Fitting the map to the data</a> and <a href="http://www.econym.demon.co.uk/googlemaps/basic15.htm">Lots of sidebar entries</a> to my maps. Check out the <a href="http://www.michelhollands.com/google_maps_pics/nz_map.html">New Zealand</a> and <a href="http://www.michelhollands.com/google_maps_pics/map_firenze.html">Firenze</a> maps.</p>
]]></content:encoded>
			<wfw:commentRss>http://michelhollands.net/blog/2007/06/26/more-google-maps-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Google map using XML</title>
		<link>http://michelhollands.net/blog/2007/06/18/creating-a-google-map-using-xml/</link>
		<comments>http://michelhollands.net/blog/2007/06/18/creating-a-google-map-using-xml/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 15:50:47 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Google maps]]></category>

		<guid isPermaLink="false">http://michelhollands.net/blog/2007/06/18/creating-a-google-map-using-xml/</guid>
		<description><![CDATA[You can also create Google Maps using XML : check out this article.]]></description>
			<content:encoded><![CDATA[<p>You can also create <a href="http://maps.google.com/">Google Maps</a> using XML : check out this<br />
<a href="http://www.engadget.com/2005/03/08/how-to-make-your-own-annotated-multimedia-google-map/">article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://michelhollands.net/blog/2007/06/18/creating-a-google-map-using-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Google maps with Python</title>
		<link>http://michelhollands.net/blog/2007/06/05/creating-google-maps-with-python/</link>
		<comments>http://michelhollands.net/blog/2007/06/05/creating-google-maps-with-python/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 17:22:52 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Google maps]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://michelhollands.net/blog/2007/06/05/creating-google-maps-with-python/</guid>
		<description><![CDATA[I guess everybody knows Google maps. This allows you to zoom into any part of the world, and in the &#8216;My Maps&#8217; part of the site you can create your own maps. These maps can be annotated, with markers and polylines. It&#8217;s also possible to create these maps programmatically. And I&#8217;ll show you how to [...]]]></description>
			<content:encoded><![CDATA[<p>I guess everybody knows <a href="http://maps.google.com/">Google maps</a>. This allows you to zoom into any part of the world, and in the &#8216;My Maps&#8217; part of the site you can create your own maps.<br />
These maps can be annotated, with markers and polylines.</p>
<p>It&#8217;s also possible to create these maps programmatically. And I&#8217;ll show you how to do this in the following. First we start with a list of adresses and descriptions :</p>
<pre>
  Auckland New Zealand,Auckland
  Rotorua New Zealand,Rotorua and Wai-O-Tapu
  Tongariro New Zealand,Mt Doom in Tongariro
</pre>
<p>On the first line &#8216;Auckland New Zealand&#8217; is the address, and &#8216;Auckland&#8217; is the description. The address will be used to lookup the place and the description will be displayed on the webpage.<br />
Let&#8217;s assume these are stored in a file called <a href="http://www.michelhollands.com/blog/wp-content/uploads/2007/06/my_locations.txt">my_locations.txt</a>.</p>
<p>Then we run the following Python <a href="http://www.michelhollands.com/blog/wp-content/uploads/2007/06/create_mappy.txt">script</a>, which prints a webpage to standard out that puts a marker on each of the location mentioned. Let&#8217;s examine this script in a bit more detail.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
&nbsp;
  key=<span style="color: #483d8b;">&quot;Put you Google Maps key here&quot;</span></pre></td></tr></table></div>

<p>Firstly we import the library urllib, which is used to load URLs from the Internet. We will call a Google Maps web service using this library. Secondly, we set up a key for Google maps. This key can be gotten from the <a href="http://www.google.com/apis/maps/signup.html">Google Maps API</a> website. This API let&#8217;s you embed the a Google Map into your own webpages. Without this key, the script will not work.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;&quot;&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 JavaScript API Example&lt;/title&gt;
      &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=%s&quot;
        type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot;&gt;
&nbsp;
      //&lt;![CDATA[
&nbsp;
      function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, &quot;click&quot;, function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }
&nbsp;
      function load() {
        if (GBrowserIsCompatible()) {
          var map = new GMap2(document.getElementById(&quot;map&quot;));
          map.addControl(new GSmallMapControl());
&nbsp;
          var point;
          var marker;
  &quot;&quot;&quot;</span> <span style="color: #66cc66;">%</span> key</pre></td></tr></table></div>

<p>Next, we print the start of the webpage. Note that this includes some javascript functions. The important one for us is the load() function. This function will be called when the page is loaded. It looks for for a div element called &#8216;map&#8217;, in which the map will be created. This function is not yet finished, the rest will be added by the script.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'my_locations.txt'</span><span style="color: black;">&#41;</span>:
      <span style="color: black;">&#40;</span>address, description<span style="color: black;">&#41;</span>=line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span>
      quoted_address=<span style="color: #dc143c;">urllib</span>.<span style="color: black;">quote_plus</span><span style="color: black;">&#40;</span>address<span style="color: black;">&#41;</span>
      url=<span style="color: #483d8b;">&quot;http://maps.google.com/maps/geo?q=%s&amp;output=csv&amp;key=%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>quoted_address,key<span style="color: black;">&#41;</span>
      f=<span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
      returnvalues=f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span>
      lat=returnvalues<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
      lng=returnvalues<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>
&nbsp;
      html=description.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
      <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;&quot;
          point = new GLatLng(%s,%s);
          marker = createMarker(point, '%s');
          map.setCenter(point);
          map.addOverlay(marker);&quot;&quot;&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>lat, lng, html<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">print</span></pre></td></tr></table></div>

<p>This code loops over the lines in the file called <a href="http://www.michelhollands.com/blog/wp-content/uploads/2007/06/my_locations.txt">my_locations.txt</a>. The we call the Google Map API, which is at &#8216;http://maps.google.com/maps/geo&#8217;. This will &#8216;geocode&#8217; the address, ie it will return the longitude and latitude of the address. The q parameter is the address you want to lookup. The output parameter specifies that we want the geocode to be returned as comma-separated values, which is an easily parseable text format. An example of this is :</p>
<pre>
  200,4,-42.108463,171.336108
</pre>
<p>200 is the return code, which is success in this case. I have no idea what the 4 means, but the last 2 values are the latitude and longitude. These are extracted and used to create a GLatLng javascript object. This object is then passed as a parameter to the createMarker function, to create the markers. An additional parameter is an HTML string that contains the description.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">   <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;&quot;        map.setCenter(point, 6);
        }
      }
&nbsp;
      //]]&gt;
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot;&gt;
      &lt;div id=&quot;map&quot; style=&quot;width: 800px; height: 800px&quot;&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  &quot;&quot;&quot;</span></pre></td></tr></table></div>

<p>Lastly, we print the end of the load() function. In the body of the page, we add a div element called map. The map will have the width and height specified.</p>
<p>An example of a map created this way (with a few embellishments such as photos added) can be found <a href="http://www.michelhollands.com/google_maps_pics/nz_map.html">here</a>.</p>
<p>Have fun !</p>
]]></content:encoded>
			<wfw:commentRss>http://michelhollands.net/blog/2007/06/05/creating-google-maps-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.868 seconds -->

