我一直在尝试运行 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编码有问题?我还不是专业人士。
thanks!
你可以这样做:
Gmaps.map.createMarker({Lat: Gmaps.map.userLocation.lat(),
Lng: Gmaps.map.userLocation.lng(),
rich_marker: null,
marker_picture: ""
})
在回调中。
请注意,您可以传递所需标记的 url。
顺便说一句,如果您觉得这是一个有用的功能,您应该在 github 上创建一个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)