Closed jah2488 closed 13 years ago
There are two helpers: gmaps
and gmaps4rails
.
The first accepts options, the second doesn't it just comes with the more common features.
See details in source code: https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/lib/gmaps4rails_helper.rb
Thanks
You're welcome, if ever you've another question please ask it on stackoverflow so that everyone could find the answer again: it's great for googling :)
WIll do, I'm actually still having trouble. I read the code and realized I should have been using the gmaps function and now the end source correctly addresses the options I specified, but the problem is that it still wont detect the location or ask for it.
<%= gmaps({
"map_options" => {
"container_id" => "connections_map_container",
"auto_adjust" => "true",
"detect_location" => "true",
"center_on_user" => "true"
}
})%>
produces
<script type="text/javascript" charset="utf-8">
function gmaps4rails_init() {
Gmaps4Rails.map_options.center_on_user = 'true';
Gmaps4Rails.map_options.container_id = 'connections_map_container';
Gmaps4Rails.map_options.detect_location = 'true';
Gmaps4Rails.map_options.auto_adjust = 'true';
Gmaps4Rails.initialize();
if(typeof gmaps4rails_callback == 'function') { gmaps4rails_callback(); }
}
window.onload = gmaps4rails_init;
However, I still have a simple world map loaded with no auto focus or detection. I'm sure its something I've done wrong. Any advice as to where to look will be great.
perhaps i should have moved this to stack overflow, lol.
Hi Justin,
I think the value "true" is causing the problem. It should be boolean (true/false) not string ("true"/"false").
Hope it helps
I've set up auto detect location in my view according to the wik, but it just continues to show a map of the world and never attempt to retrieve the user's location. Perhaps I am doing it wrong?
<%= gmaps4rails({ "map_options" => { "container_id" => "connections_map_container", "auto_adjust" => "true", "detect_location" => "true", "center_on_user" => "true" } })%>