如何在gmaps4rails中使用标记显示用户的位置?

我一直试图自定义使用gmaps4rails运行,我的代码设置在地图上显示我的json坐标字符串,用户IS的中心工作,我可以放大我家的位置,工作和我的电话。 一旦获得许可,我就无法让js在地图上显示“我在这里”按钮。

这是我用于gmaps4rails地图的代码:

 {:detect_location => true, :center_on_user => true, :auto_zoom => false, :zoom => 12, :auto_adjust => true}, :markers => {:data => @json} ) %> 

谢谢你的帮助!

编辑12月6日回答:

我正在添加回调代码,如下所示:

   Gmaps.map.callback = function() { Gmaps.map.createMarker({Lat: Gmaps.map.userLocation.lat(), Lng: Gmaps.map.userLocation.lng(), rich_marker: null, marker_picture: "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/heart30.png" }) }  

并且仍未在地图上得到回复。 这是我的js编码的问题吗? 我不是职业选手。

谢谢!

你可以这样做:

 Gmaps.map.createMarker({Lat: Gmaps.map.userLocation.lat(), Lng: Gmaps.map.userLocation.lng(), rich_marker: null, marker_picture: "" }) 

在回调中。


请注意,您可以传递所需标记的url。

顺便说一句,你应该在github上创建一个问题,如果你觉得这是一个有用的function。