<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/controllers/chap_four_controller.rb</filename>
    </added>
    <added>
      <filename>app/helpers/chap_four_helper.rb</filename>
    </added>
    <added>
      <filename>app/models/store.rb</filename>
    </added>
    <added>
      <filename>app/views/chap_four/map.html.erb</filename>
    </added>
    <added>
      <filename>db/migrate/20080627051703_create_stores.rb</filename>
    </added>
    <added>
      <filename>lib/tasks/geocoding_tasks.rake</filename>
    </added>
    <added>
      <filename>public/javascripts/application_chap_three.js</filename>
    </added>
    <added>
      <filename>test/fixtures/stores.yml</filename>
    </added>
    <added>
      <filename>test/functional/chap_four_controller_test.rb</filename>
    </added>
    <added>
      <filename>test/unit/store_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,11 @@
-Sample codes from the book [Beginning Google Maps Applications with Rails and Ajax: From Novice to Professional](http://www.amazon.com/Beginning-Google-Maps-Applications-Rails/dp/1590597877)
+Sample codes from the book [Beginning Google Maps Applications with Rails and Ajax: From Novice to Professional](http://www.amazon.com/Beginning-Google-Maps-Applications-Rails/dp/1590597877).
 
-This sample is of Rails 2.1, using Sqlite3.
+The book's site is http://googlemapsbook.com/ .
 
-The source code from the book has some typos, and some of them don't work. I've tried my best to make the it work.
+This sample uses Rails 2.1 and Sqlite3.
+
+The source code from the book has some typos, and some of them don't work. I've tried my best to make it work.
+
+Thanks to the authors of the book, for bringing us this book, and for allowing me to use the source code and make it public on github.
 
 The Chinese translation of the book sucks, see http://blog.ashchan.com/archive/2008/06/25/professional-book/ .
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,15 @@
+# == Schema Information
+# Schema version: 20080627051703
+#
+# Table name: markers
+#
+#  id    :integer         not null, primary key
+#  lat   :decimal(, )     
+#  lng   :decimal(, )     
+#  found :string(100)     
+#  left  :string(100)     
+#  icon  :string(100)     default(&quot;&quot;)
+#
+
 class Marker &lt; ActiveRecord::Base
 end</diff>
      <filename>app/models/marker.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@
     &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAApuqJ-ievoI8n0KBpKtZuyxTJQa0g3IQ9GZqIMmInSLzwtGDKaBSt40PUewe_UUsm_5pWXNbz5adklA&quot;
       type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 
-      &lt;%= javascript_include_tag 'prototype', 'application' %&gt;
+      &lt;%= javascript_include_tag 'prototype', 'application_chap_three' %&gt;
   &lt;/head&gt;
   &lt;body&gt;
     &lt;div id=&quot;map&quot; style=&quot;width: 800px; height: 500px&quot;&gt;&lt;/div&gt;</diff>
      <filename>app/views/chap_three/map.html.erb</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>db/development.sqlite3</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version =&gt; 20080626030014) do
+ActiveRecord::Schema.define(:version =&gt; 20080627051703) do
 
   create_table &quot;markers&quot;, :force =&gt; true do |t|
     t.decimal &quot;lat&quot;
@@ -19,4 +19,16 @@ ActiveRecord::Schema.define(:version =&gt; 20080626030014) do
     t.string  &quot;icon&quot;,  :limit =&gt; 100, :default =&gt; &quot;&quot;
   end
 
+  create_table &quot;stores&quot;, :force =&gt; true do |t|
+    t.string &quot;name&quot;,     :limit =&gt; 50
+    t.string &quot;address&quot;,  :limit =&gt; 100
+    t.string &quot;address2&quot;, :limit =&gt; 100
+    t.string &quot;city&quot;,     :limit =&gt; 50
+    t.string &quot;state&quot;,    :limit =&gt; 2
+    t.string &quot;zip&quot;,      :limit =&gt; 9
+    t.string &quot;phone&quot;,    :limit =&gt; 15
+    t.string &quot;lat&quot;,      :limit =&gt; 20
+    t.string &quot;lng&quot;,      :limit =&gt; 20
+  end
+
 end</diff>
      <filename>db/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,108 +1,21 @@
 var map;
-var centerLatitude = 37.4419;
-var centerLongitude = -122.1419;
-var startZoom = 12;
-
-function createMarker() {
-	var lng = $('longitude').value;
-	var lat = $('latitude').value;
-	var formValues = Form.serialize('geocache-input');
-	new Ajax.Request('create',
-		{
-			parameters: formValues,
-			onComplete: function(request) {
-				res = eval(&quot;(&quot; + request.responseText + &quot;)&quot;);
-				
-				if (!res.success) {
-					alert(res.content);
-				}
-				else {
-					var latlng = new GLatLng(parseFloat(lat), parseFloat(lng));
-					var marker = addMarkerToMap(latlng, res.content, res.icon);
-					map.addOverlay(marker);
-					map.closeInfoWindow();
-				}
-			}
-		});
-
-	return false;
-}
-
-function listMarkers() {
-	var request = GXmlHttp.create();
-	request.open('GET', 'list', true);
-	request.onreadystatechange = function() {
-		if (request.readyState == 4) {
-			markers = eval(&quot;(&quot; + request.responseText + &quot;)&quot;);
-			for (var i = 0; i &lt; markers.length; ++i) {
-				var marker = markers[i].marker;
-				var lat = marker.lat;
-				var lng = marker.lng;
-				
-				if (lat &amp;&amp; lng) {
-					var latlng = new GLatLng(parseFloat(lat), parseFloat(lng));
-					
-					var html = '&lt;div&gt;&lt;strong&gt;Found&lt;/strong&gt; '
-					+ marker.found
-					+ '&lt;/div&gt;&lt;div&gt;&lt;strong&gt;Left&lt;/strong&gt; '
-					+ marker.left
-					+ '&lt;/div&gt;';
-
-					map.addOverlay(addMarkerToMap(latlng, html, marker.icon));
-				}
-			}
-		}
-	}
-	
-	request.send(null);
-}
-
-function addMarkerToMap(latlng, html, iconImage) {
-	if (iconImage != &quot;&quot;) {
-		var icon = new GIcon();
-		icon.image = iconImage;
-		icon.iconSize = new GSize(25, 25);
-		icon.iconAnchor = new GPoint(14, 25);
-		icon.infoWindowAnchor = new GPoint(14, 14);
-		var marker = new GMarker(latlng, icon);
-	}
-	else {
-		var marker = new GMarker(latlng);
-	}
+var centerLatitude = 40.6897;
+var centerLongitude = -95.0446;
+var startZoom = 3;
+
+var RonJonLogo = new GIcon();
+RonJonLogo.image = &quot;http://book.earthcode.com/chapter4/StoreLocationMap/ronjonsurfshoplogo.png&quot;
+RonJonLogo.iconSize = new GSize(48, 24);
+RonJonLogo.iconAnchor = new GPoint(24, 14);
+RonJonLogo.infoWindowAnchor = new GPoint(24, 24);
+
+function addMarker(latitude, longitude, description) {
+	var marker = new GMarker(new GLatLng(latitude, longitude), RonJonLogo);
+	GEvent.addListener(marker, 'click',
+		function() { marker.openInfoWindowHtml(description); }
+	);
 	
-	GEvent.addListener(marker, 'click', function() {
-		var markerHTML = html;
-		marker.openInfoWindowHtml(markerHTML);
-	});
-	return marker;
-}
-
-function onMapClick(overlay, latlng) {
-	/* click on a marker also tiggers this event, but without a latlng value*/
-	if (!latlng)
-		return;
-		
-	var inputForm = document.createElement(&quot;form&quot;);
-	inputForm.setAttribute(&quot;action&quot;, &quot;&quot;);
-	inputForm.onsubmit = function() { createMarker(); return false; }
-	inputForm.id = 'geocache-input';
-
-	var lng = latlng.lng();
-	var lat = latlng.lat();
-
-	inputForm.innerHTML = '&lt;fieldset style=&quot;width:150px;&quot;&gt;'
-	+ '&lt;legend&gt;New Marker&lt;/legend&gt;'
-	+ '&lt;label for=&quot;found&quot;&gt;Found&lt;/label&gt;'
-	+ '&lt;input type=&quot;text&quot; id=&quot;found&quot; name=&quot;m[found]&quot; style=&quot;width: 100%;&quot; /&gt;'
-	+ '&lt;label for=&quot;left&quot;&gt;Left&lt;/label&gt;'
-	+ '&lt;input type=&quot;text&quot; id=&quot;left&quot; name=&quot;m[left]&quot; style=&quot;width: 100%;&quot; /&gt;'
-	+ '&lt;label for=&quot;icon&quot;&gt;Icon URL&lt;/label&gt;'
-	+ '&lt;input type=&quot;text&quot; id=&quot;icon&quot; name=&quot;m[icon]&quot; style=&quot;width: 100%&quot; /&gt;'
-	+ '&lt;input type=&quot;submit&quot; value=&quot;Save&quot; /&gt;'
-	+ '&lt;input type=&quot;hidden&quot; id=&quot;longitude&quot; name=&quot;m[lng]&quot; value=&quot;' + lng + '&quot; /&gt;'
-	+ '&lt;input type=&quot;hidden&quot; id=&quot;latitude&quot; name=&quot;m[lat]&quot; value =&quot;' + lat + '&quot; /&gt;'
-	+ '&lt;/fieldset&gt;';
-	map.openInfoWindow(latlng, inputForm);
+	map.addOverlay(marker);
 }
 
 function init() {
@@ -110,12 +23,12 @@ function init() {
 	return;
 	
 	map = new GMap2(document.getElementById(&quot;map&quot;));
-	listMarkers();
 	map.addControl(new GSmallMapControl());
-	map.addControl(new GMapTypeControl());
 	map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
 
-	GEvent.addListener(map, 'click', onMapClick);
+	for (i = 0; i &lt; stores.length; ++i) {
+		addMarker(stores[i].lat, stores[i].lng, stores[i].name)
+	}
 }
 
 window.onload = init;</diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,16 @@
+# == Schema Information
+# Schema version: 20080627051703
+#
+# Table name: markers
+#
+#  id    :integer         not null, primary key
+#  lat   :decimal(, )     
+#  lng   :decimal(, )     
+#  found :string(100)     
+#  left  :string(100)     
+#  icon  :string(100)     default(&quot;&quot;)
+#
+
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 
 # one:</diff>
      <filename>test/fixtures/markers.yml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>07c19300fb7716ae1e886f401f7a83108e969fb6</id>
    </parent>
  </parents>
  <author>
    <name>ashchan</name>
    <email>ashchan@gmail.com</email>
  </author>
  <url>http://github.com/ashchan/google_maps_example/commit/b6b175b31a09c60363f1122f832c44ce52b3b49c</url>
  <id>b6b175b31a09c60363f1122f832c44ce52b3b49c</id>
  <committed-date>2008-06-27T00:09:29-07:00</committed-date>
  <authored-date>2008-06-27T00:09:29-07:00</authored-date>
  <message>chapter four</message>
  <tree>360d34bd2a4a850c3cbcf23beaa72e27921f9496</tree>
  <committer>
    <name>ashchan</name>
    <email>ashchan@gmail.com</email>
  </committer>
</commit>
