Ruby on rails 3 gmaps4rails检测_位置未显示标记

Ruby on rails 3 gmaps4rails检测_位置未显示标记,ruby-on-rails-3,gmaps4rails,Ruby On Rails 3,Gmaps4rails,我正在使用rails 3.2.12中的gem“gmaps4rails”,我在map_选项中设置了detect_location=“true”,但它没有显示任何带有用户当前位置的标记 以下是代码: <%= gmaps("map_options" => {"auto_adjust" => true, "detect_location" => true, "center_on_user" => true, "auto_zoom" => false, "radius"

我正在使用rails 3.2.12中的gem“gmaps4rails”,我在map_选项中设置了detect_location=“true”,但它没有显示任何带有用户当前位置的标记

以下是代码:

<%= gmaps("map_options" => {"auto_adjust" => true, "detect_location" => true, "center_on_user" => true, "auto_zoom" => false, "radius" => 2500},
  "markers" => {"data" => @json, "options" => {"list_container" => "markers_list","randomize" => true,"max_random_distance" => 10000, "draggable" => true, "dblclick" => "latLng"} }
{“自动调整”=>true,“检测位置”=>true,“在用户上居中”=>true,“自动缩放”=>false,“半径”=>2500},
“markers”=>{“data”=>@json,“options”=>{“list\u container”=>“markers\u list”,“randomize”=>true,“max\u random\u distance”=>10000,“draggable”=>true,“dblclick”=>“latLng”}
如何显示用户当前位置的标记

请帮帮我。 提前感谢创业板“gmaps4rails”

如果我们给出选项
“detect_location”=>true
,当地图加载到页面上时,它会向用户显示弹出窗口“允许应用程序使用您的位置”,并给出是和否选项

如果用户选择“是”,则将地图居中到用户的位置

现在,您希望显示用户位置的标记,然后您必须自己添加标记

这可以通过以下方式完成:

控制器:

geo = request.location
@latitude  = geo.latitude
@longitude = geo.longitude
通过页面加载,您可以使用此回调为用户添加标记

这将在页面上加载地图时为当前用户位置添加标记

- content_for :scripts do
  %script{:type => "text/javascript"}
    Gmaps.map.callback = function(){
    google.maps.event.addListenerOnce(Gmaps.map.serviceObject, 'idle', function(){
    / add user pin
    var home_pin = [{picture: "current_user.png", width: 32, lat: "#{@latitude}", lng: "#{@longitude}"}];
    Gmaps.map.addMarkers(home_pin)
    }
    )};
希望这对你有帮助

如果你还面临任何问题,请告诉我

谢谢