views:

194

answers:

3

Here's some background of my problem:

I am on Snow Leopard I have RVM installed(using a ruby1.9.2-head installation) I am using rails3 I installed the ym4r using this http://github.com/guilleiguaran/ym4r_gm (and followed the tutorial)

Anyway, I added these to my controller:

@map = GMap.new("map_div")
@map.control_init(:large_map => true,:map_type => true)
@map.center_zoom_init([75.5,-42.56],4)
@map.overlay_init(GMarker.new([75.6,-42.467],:title => "Hello", :info_window => "Info! Info!"))

then these to my view:

Test <%= raw(GMap.header) %>  <%= raw(@map.to_html) %>  <%= raw(@map.div(:width => 600, :height => 400)) %>  

well actually im using haml(does it matter?)

Test
= raw(GMap.header)
- unless @map.blank?
  = raw(@map.to_html)
#map{:style => "width: 600px; height: 400px"}

problem is i keep getting a

Showing /Users/eumir/rails_apps/evo-lux/app/views/layouts/_map.html.haml where line #11 raised:

can't convert Ym4r::GmPlugin::Variable to String (Ym4r::GmPlugin::Variable#to_str gives Ym4r::GmPlugin::Variable)

Extracted source (around line #11):

9: Test 10: = raw(GMap.header) 11: = raw(@map.to_html) 12: = raw(@map.div(:width => 600, :height => 400))

which is totally weird. I can't double check with debugger(it's another error altogether...my rails cant find ruby-debugger)

so im really kinda stumped. Any help?

A: 

Ok should've RTFM. Some discoveries:

  • the plugin was made for the now deprecated google maps v2 API
  • the to_html function of the plugin is a bit off in the sense that the init variables for the html variables is an array of variables - which are being joined by a string.
corroded
So, what is your go now? Did you found antything nice to work with Rails and v3 api? Or you just using plain JS api?
mdrozdziel
A: 

What approach did you take to resolve the problem? Thanks. Steve

Steve
+1  A: 

The following function needs to be added to class Variable in mapping.rb of the plugin.

def to_str @variable + ";" end

Array#* gets called in the to_html function and Ruby 1.9.2 uses to_str instead of to_s to join the values.

fonemstr