Permalink
Browse files

Some more testing goodies for Gmap & Gicon interface

  • Loading branch information...
1 parent 3fb14ac commit 4db8e974f9bd9cd9aa582a67bbcde21067a83900 @parolkar parolkar committed Jan 5, 2011
Showing with 380 additions and 303 deletions.
  1. +3 −0 init.rb
  2. +1 −0 lib/init.rb
  3. +42 −0 lib/v3/cartographer/gicon.rb
  4. +243 −257 lib/v3/cartographer/gmap.rb
  5. +1 −1 lib/v3/cartographer/gmarker.rb
  6. +46 −43 lib/v3/cartographer/header.rb
  7. +29 −0 spec/gicon_spec.rb
  8. +15 −2 spec/gmap_spec.rb
View
@@ -0,0 +1,3 @@
+#Rails 3 looks for init.rb in root of plugin
+
+require File.dirname(__FILE__) + '/lib/init'
View
@@ -23,6 +23,7 @@
require 'v3/cartographer'
require 'v3/cartographer/header'
require 'v3/cartographer/gmap'
+ require 'v3/cartographer/gicon'
Cartographer
Cartographer::Header
@@ -0,0 +1,42 @@
+class Cartographer::Gicon
+ attr_accessor :name,
+ :width, :height,
+ :shadow_width, :shadow_height,
+ :image_url, :shadow_url,
+ :anchor_x, :anchor_y,
+ :info_anchor_x, :info_anchor_y
+
+ def initialize( options = {} )
+ @name = options[:name] || 'icon'
+ @image_url = options[:image_url] || 'http://www.google.com/mapfiles/marker.png'
+ @shadow_url = options[:shadow_url] || 'http://www.google.com/mapfiles/shadow50.png'
+ @width = options[:width] || 20
+ @height = options[:height] || 34
+ @shadow_width = options[:shadow_width] || 37 #to be deprecated
+ @shadow_height = options[:shadow_height] || 34 #to be deprecated
+ @anchor_x = options[:anchor_x] || 6
+ @anchor_y = options[:anchor_y] || 20
+ @info_anchor_x = options[:anchor_x] || 5 #to be deprecated
+ @info_anchor_y = options[:anchor_y] || 1 #to be deprecated
+ end
+
+ # turn the object into valid js
+ def to_js
+ "var #{@name} = new google.maps.MarkerImage(
+ \"#{@image_url}\",
+ google.maps.Size(#{@width},#{@height}),
+ google.maps.Point(0,0),
+ google.maps.Point(#{@anchor_x},#{@anchor_y}),
+ google.maps.Size(#{@width},#{@height})
+ );
+ "
+
+
+ end
+
+ def to_html
+ "<script type='text/javascript'>
+ #{to_js}
+ </script>\n"
+ end
+end
Oops, something went wrong.

0 comments on commit 4db8e97

Please sign in to comment.