polymaps
polymaps copied to clipboard
Polymaps lets you overlay clickable polygons on top of a google map with your specified geo-coded regions
= Polymaps - Ruby Polygon overlays for Google Maps
- http://www.kangarooit.com/polymaps/polymaps_rails_plugin.php
- http://groups.google.com/group/polymaps
- http://github.com/cornflakesuperstar/polymaps
== Description
Polymaps lets you overlay clickable polygons on top of a google map with your specified geo-coded regions.
== Example Code
class Country < ActiveRecord::Base has_many :regions validates_presence_of :code # eg. 'AU' end
class Region < ActiveRecord::Base belongs_to :country has_many :points validates_presence_of :name # eg. 'Victoria' end
class Point < ActiveRecord::Base belongs_to :region validates_presence_of :lat, :lng end
view.html.erb: <% country = Country.find_by_code("TW") -%> <% polygons = PolyMaps::Renderer.new(country.code, country.regions, 'points', 'document.location.href='/regions/show/#{region.id}'' ) %>
== Example Output
== Usage Doc
<% polygons = PolyMaps::Renderer.new(country_code, regions_collection, relationship_name, onclick_handler, polygon_limit) -%> <%= polygons.js %>
@param country_code consisting of two letters and complying to the ISO 3166-1 alpha-2 standard
@param regions_collection objects will be checked for a 'name' attribute which will display as the polygon label (if it exists)
@param relationship_name refers to the region objects relationship name specifying the child 'ordinate' objects (which must each have a 'lat' and 'lng' attribute)
@param onclick_handler will be interpreted and assumes a 'region' object will be in scope
@param polygon_limit (optional) can be set to limit the number of polygons that are rendered for javascript performance purposes (you don't really want a gazillion points being rendered on your map do you?)
== Troubleshooting
Check your console for 'Polymaps Unsupported country code: ..' messages. The lib/country_centers_and_zooms.yml needs more data (I use http://www.kangarooit.com/developer_blog/hover_lat_lng.html to get this data by plotting a rectangle around each country)
If you install as a gem, make sure the require statement has an underscore in the name (require "poly_maps" )
== Install for Rails
First, ensure that you’re running at least RubyGems 1.2 (check gem -v if you’re not sure).
The polymaps gem is built by GitHub. Add GitHub to your gem sources (once per machine):
gem sources -a http://gems.github.com
Install the library:
gem install cornflakesuperstar-polymaps
To enable the library, load it at the end of “config/environment.rb”
require "poly_maps"
To install the latest code as a plugin:
script/plugin install git://github.com/cornflakesuperstar/polymaps.git
== Authors
- Developed by {Jason Kotchoff}[http://www.kangarooit.com/contact_us.php]
== License
Copyright (c) 2009 Jason Kotchoff. See MIT-LICENSE.txt in this directory.