Archive Page 3
Well, we had a number of requests by email for an explanation of how to set this up with clickable markers, so here it is. First, I’ve made a new version of the demo, which now features the traditional infoWindow popups, triggered by either marker clicks or selection from the sidebar.
The Ruby on Rails code is ready to downloaded. Here’s how to get it up and running in your environment:
- Download the zip file, gmaps_rails_code.zip
- Create your own empty Rails application (rails your_app_name)
- Unzip gmaps_rails_code.zip in the root of your newly created application. When you unzip the file, you will see it contains five root directories: app, db, lib, public, standalone_scripts. You want these directories to overlay the directories of your own Rails application.
- set up your config/database.yml as appropriate for your environment. Most people just use root/no password for their development environment.
- in routes.rb, add a line to configure the home_url:
map.home '', :controller => 'app', :action=>'index'
rake db:migrateto load the schema.
- In your config/environments/development.rb, add a line to specify your own Google Maps API key:
- Start your rails server, and go to http://localhost:3000/app (or adjust if your server is on a different port). You should see a welcome page and links to all the chapter examples.
These steps will give you the code and an empty database. This is meant to set the stage for you work with the various examples in the book. You will need to run the various data imports (capitol city scaping, FCC structure import, TIGER/Line data processing, etc) per the instructions in the book to fully populate the database.
After following the steps here, the examples in chapters 2,3,9, and 10 should work immediately. The rest of the chapters require some amount of data (primarily the FCC towers data), so you will need to load that data for the examples to work.
The Google Maps key is the primary configuration setting you need to get started. There are some others you will need for later chapters, however. You can add these to config/environments/development.rb file as well:
UK_POSTCODE_DIR="/path/to/your/uk/postcode/data" #the directory, not the file
Finally, note that the Ruby on Rails examples are live at http://book.earthcode.com.
To those of you who have emailed us about the source code for the Rails edition — thanks for your patience, it’s coming soon! I decided to present it as a one compressed file you can unpack over an existing Rails application skeleton. Stay tuned, the code is coming later today or tomorrow at the latest.
Andre Lewis has been hard at work since September 2006 translating and rewriting the PHP-centric edition of our Beginning Google Maps Applications book into Ruby on RAILS — and we’re giving away
3 4 copies over the next 3 weeks!
If you’re interested in entering the contest please simply visit http://googlemapsbook.com/contest and fill out the form. We’ll randomly draw three winners on the 15th of March, 2007 and ship some shiny new books.
Please feel free to share the link with all of your friends and user groups. If we get an overwhelming response we may give away a few bonus copies to increase your odds of winning.
About our new book
All of the easy to follow examples that you’ve come to love from the PHP edition are still here, only they are now implemented in the Model-View-Controller paradigm that Rails uses at it’s core. The book won’t teach you RAILS anymore than our first book taught you PHP, but if you’re already familiar with RAILS then you will love the impressive and educational examples in this book.
For those of you who can’t wait three weeks to find out, Beginning Google Maps Applications with RAILS and Ajax is now available from our favorite online book retailer. A spare copy never hurt anyone :)
Andre Lewis has been hard at work writing our new sister book Beginning Google Maps with RAILS and Ajax. It’s due back from the printers in about a week, so on the eve of its release he has also released GeoKit for Rails along with Bill Eisenhauer. Bill also has a few examples on his site. Check them out.
From the site:
Geokit is a Rails plugin for building location-based apps. It provides geocoding, location finders, and distance calculation in one cohesive package. If you have any tables with latitude/longitude columns in your database, or if you every wanted to easily query for “all the stores within a 50 mile radius,” then GeoKit is for you.
What can GeoKit do for you?
- Distance calculations between two points on the earth. Calculate the distance in miles or KM, with all the trigonometry abstracted away by GeoKit.
- ActiveRecord distance-based finders. For example, you can find all the points in your database within a 50-mile radius.
- Geocoding from multiple providers. It currently supports Google, Yahoo, Geocoder.us, and Geocoder.ca geocoders, and it provides a uniform response structure from all of them. It also provides a fail-over mechanism, in case your input fails to geocode in one service.
- IP-based location lookup utilizing hostip.info. Provide an IP address, and get city name and latitude/longitude in return.
- A before_filter helper to geocode the user’s location based on IP address, and retain the location in a cookie.
If this is interesting to you consider helping us get the word out for Andre and Bill by digging the announcement for them.
Keep an eye out for a chance to win a copy of his new book in the next few days and be the first in your local RUG to get it!
Buy Our Books!(Here's Why)
You are currently browsing the Beginning Google Maps Applications weblog archives.