hey everyone
I’m trying to implement a google map in my application using the ym4r
framework.
Accessing the action directly using the url /controller/action works
fine.
However, when i use link_to_remote or render_component to display the
action that has the map, it just renders a blank div.
Does anyone have any idea on what could be happening or how should i
load it properly?
Here’s how i’m declaring the link:
<%= link_to_remote ‘Mapa’,
:update => ‘main-window’,
:method => ‘get’,
:url => { :controller => ‘country’, :action => ‘index’} %>
Thanks in advance,
Ricardo Silveira C.
the link appears to be functional. the problem is most likely in the
action
On 6/3/07, Ricardo Silveira C. [email protected] wrote:
load it properly?
Here’s how i’m declaring the link:
<%= link_to_remote ‘Mapa’,
:update => ‘main-window’,
:method => ‘get’,
:url => { :controller => ‘country’, :action => ‘index’} %>
Hi Ricardo,
I don’t think the problem is in your link_to_remote, if you have the
id ‘main-window’ and is updating it with a ‘blank div’ that link is
doing something. Are you sure you the output you are getting from
country/index is what you want?
Can you give us the country/index action code and the view code too?
My advice would be: try it without ajax and do some tests, after you
are sure of what is it doing, add ajax just to: “make it suck less”.
Suerte!
if i load localhost:3000/country/ the map appears just as it is supposed
to.
here’s the code for country/index action and view:
country_controller.rb:
def index
@map = GMap.new(“map_div”)
@map.control_init(:large_map => true,:map_type => true)
@map.center_zoom_init([37.735,-25.672],4)
end
country/index.rhtml
<%= GMap.header(:with_vml => false) %>
<%= @map.to_html %>
<%= @map.div(:width => ‘500’, :height=>‘400’) %>
Thanks for answering!
Ricardo Silveira C.
I don’t think the problem is in your link_to_remote, if you have the
id ‘main-window’ and is updating it with a ‘blank div’ that link is
doing something. Are you sure you the output you are getting from
country/index is what you want?
Can you give us the country/index action code and the view code too?
My advice would be: try it without ajax and do some tests, after you
are sure of what is it doing, add ajax just to: “make it suck less”.
Suerte!
Hi Ricardo,
I was trying the same thing several weeks ago and it was giving me a
hard time. I would check to make sure that your’re not getting any
conflicts between the index.rhtml markup and the template that’s
actually calling it.
Perhaps something strange is happening to the GMap header while it’s
being rendered into a template other than index.rhtml:
<%= GMap.header %>
<%= @map.to_html %>
I don’t know…I ended up just using a lame popup to display the map
instead of ajax; I’ll go back and rework it and post the results here.
Jim
What do you mean by conflicts? i have
<%= GMap.header(:with_vml => false) %>
declared on both the head of the layout and in country/index.rhtml,
but i’ve tried every combination of header declarations with these two
files to no avail.
I’ve uploaded my latest code to the site (with it’s respective google
maps api key :)) to
http://sattagis1.dza.fc.ul.pt:3000/
if you want to take a look. The problematic link_to_remote to country/
index is the word ‘Mapa’ in the second menu.
Thanks,
Ricardo Silveira C.
For everyone trying the same thing:
Guilhem Vellut suggested changing
<%= @map.to_html %>
to
<%= @map.to_html :no_load => true %>
which fixed the situation.
Ricardo