没有直接的方法来实现你想要的gmaps4rails
,至少不是它的两个部分:
单击地图并创建标记属于您
检索到这两个地方后,gem 可以处理显示目的地。
在您看来,您应该添加以下 ruby 代码(以以下选项为例,这里的帮助程序的唯一目的是创建地图):
<%= gmaps( "map_options" => { "center_on_user" => true, "zoom" => 5 }) %>
然后你可以包括javascript:
//starting point
Gmaps4Rails.direction_conf.origin = from_var_string;
//where to go
Gmaps4Rails.direction_conf.destination = to_var_string;
//if you want to display a panel with the instructions
Gmaps4Rails.direction_conf.display_panel = true;
//pass here the id of the panel
Gmaps4Rails.direction_conf.panel_id = 'instructions';
//set the travel mode
Gmaps4Rails.direction_conf.travelMode = 'DRIVING';
//add one or more waypoints
Gmaps4Rails.direction_conf.waypoints = [{"stopover":true,"location": waypoint1_string},{"stopover":true,"location": waypoint2_string}];
//trigger the creation
Gmaps4Rails.create_direction();