3

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

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

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

谢谢你的帮助!

回答后编辑 12 月 6 日:

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

        <script type="text/javascript" charset="utf-8">
         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"
                   })
                }
        </script>

仍然没有在地图上得到回应。这是我的js编码的问题吗?我还不是专业人士。

谢谢!

4

1 回答 1

2

你可以这样做:

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

在回调中。


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

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

于 2011-12-06T20:05:14.803 回答