0
我需要在地圖上顯示當前用戶位置。我正在使用gem gmaps4rails。這是我的觀點,我只是在github上找到教程並在頁面上構建地圖,但在教程中沒有關於用戶位置功能的說法。Gmaps4rails位置集
<script src="//maps.google.com/maps/api/js?key=my api key"></script>
<script src="//cdn.rawgit.com/mahnunchik/markerclustererplus/master/dist/markerclusterer.min.js"></script>
<script src='//cdn.rawgit.com/printercu/google-maps-utility-library-v3-read-only/master/infobox/src/infobox_packed.js' type='text/javascript'></script>
<p id="notice"><%= notice %></p>
<div style='width: 320px;'>
<div id="map" style='width: 320px; height: 400px;'></div>
</div>
<script type="text/javascript">
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
var markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
</script>