我一直在試圖獲得gmaps4rails運行的自定義使用,並且我已將代碼設置爲在地圖上顯示我的json座標字符串,並且用戶的工作中心正在工作,我可以從家中放大我的位置,工作和我的手機。一旦授予權限,我無法讓js在地圖上顯示「我在這裏」按鈕。如何使用gmaps4rails中的標記顯示用戶的位置?
這裏是我使用的地圖從gmaps4rails代碼:
<%= gmaps(:map_options => {:detect_location => true, :center_on_user => true, :auto_zoom => false, :zoom => 12, :auto_adjust => true}, :markers => {:data => @json}) %>
感謝您的幫助!
編輯答案Dec.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編碼的問題嗎?我還沒有親。
謝謝!在回調
Gmaps.map.createMarker({Lat: Gmaps.map.userLocation.lat(),
Lng: Gmaps.map.userLocation.lng(),
rich_marker: null,
marker_picture: ""
})
:
對不起,我不是很瞭解您的問題 – apneadiving
@apneadiving THanks閱讀它,我將重新說明:嘗試顯示Gmaps4rails.map.userLocation數據的標記。目前地圖將以用戶爲中心,但不顯示標記。即:就像在商場/機場的「你在這裏」箭頭一樣。希望有所幫助? – keade
ok gotcha,不要忘記接受答案(新用戶通知) – apneadiving