我正在使用GM4Rails宝石。
我是Rails的新手,我正在尝试找到配置文件,因此我可以使用HYBRID Google Maps而不是ROADMAP。
我找不到文件:https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Map
无论如何我可以更改配置吗?
答案 0 :(得分:3)
你必须知道:
<%= gmaps4rails(@json) %>
是:
的快捷方式<%= gmaps("map_options" => { "auto_adjust" => true},
"markers" => { "data" => @json })
%>
如果您需要传递其他选项,则必须使用gmaps
帮助。在你的情况下:
<%= gmaps("map_options" => { "auto_adjust" => true, "type" => "HYBRID" },
"markers" => { "data" => @json })
%>
如您所见,还有更多选择。
答案 1 :(得分:0)
如果您直接调用Gmaps.loadMaps();
函数,请使用:
search_map = new Gmaps4RailsGoogle();
Gmaps.search_map = search_map;
search_map.map_options.raw.streetViewControl = false; // yes, raw
// more options
search_map.map_options.id = "search_map";
search_map.map_options.maxZoom = 14;
search_map.map_options.zoom = 12;
Gmaps.loadMaps();
我对其余代码(它来自旧的代码库)不太确定,但您要查找的行是search_map.map_options.raw.streetViewControl = false;
答案 2 :(得分:-1)
因此,要显示地图,请使用以下代码:
<%= gmaps({
"map_options" => {"container_id" => "connections_map_container", "auto_adjust" => "true", "bounds" => '[{"lat": 0, "lng": 0 }, {"lat": 80 , "lng": 100 }]'},
... #add here data you want to display
})
%>
这是您传递地图选项的地方,因此您可以在该行的任何位置插入"type" => "HYBRID"
因此修改后的示例看起来像
<%= gmaps({
"map_options" => {"container_id" => "connections_map_container", "auto_adjust" => "true", "bounds" => '[{"lat": 0, "lng": 0 }, {"lat": 80 , "lng": 100 }]'}, "type" => "HYBRID"
... #add here data you want to display
})
%>