开发者

Google-maps-for-Rails without a Model

Sorry to be newbie, but i wanna draw your attention to my problem while using gmaps4rails - great gem.

In my app there is no database backend. Actually i just want to collect markers like this:

<% markers=[]%>
<% @search.each do |dish| %>
<% if (not dish.restaurant.nil?)
    restaurant=Restaurant.where( :id  => dish.restaurant["Id"])
    markers<< {:longitude => restaurant.lng , :latitude=> restaurant.lat}
  end%>
<div id="dish_listed"><%= render 'dish_listed',  :dish => dish %></div>
<% end %>
<%= gmaps4rails(markers.to_json) %>

Unfortunately it displays a gray rectangular whithout a map *( I`ve managed to follow the steps from Wiki (i did it several times *))))

When i do

markers.to_json

i get

"[{\"longitude\":"30.252442359924316",\"latitude\":"59.92999013067258"}]" 

And i have no idea why kind of code

<%= gmaps4rails('[{\"lng\":"30.252442359924316",\"lat\":"59.92999013067258"}]') %>

doesnt work? Where should it be initialized? Or what magic steps did i forget? I also forked a project by thasuresh. Started it and the removed everything from the model, and pushed my markers there, and it displayed me just what i wanted.

But i still cant reach the same resu开发者_Python百科lt on the project i write by my self!!!

-----And now i`m sitting here and waiting for flying tomatos *)))-----

PS rails 3.1rc5 gmaps4rails 0.10.2

BTW Could it be no gmappable model?


This works:

<%= gmaps4rails('[{"lng":"30.252442359924316","lat":"59.92999013067258"}]') %>

There are still little fixes to do for Rails 3.1, some threads are open on github.

To adjust the zoom level with one marker, check this question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜