Gmaps4rails を使用しています。それは本当にうまくいっています。しかし、ブラウザを介してユーザーの位置情報を取得しようとすると問題が発生しました。
私の見解:
<%= gmaps(:markers => { :data => @json},
:map_options => { :container_class => "map_container",:id => "map",:class => "gmaps4rails_map"},
:scripts => :none ) %>
<% content_for :scripts do %>
<script type="text/javascript">
Gmaps.map.callback = function() {
setInterval(function(){Gmaps.map.createMarker({
Lat: Gmaps.map.userLocation.lat(),
Lng: Gmaps.map.userLocation.lng(),
rich_marker: null,
marker_picture: "/images/icon.png",
})},10000)
}
</script>
<% end %>
gmaps4railsでマーカーを使用してユーザーの位置を表示するにはどうすればよいですか? で説明されているように、ブラウザーの地理位置情報遅延の setinterval メソッドを試しました
私のgmapsコーヒースクリプト
detect_location: true # should the browser attempt to use geolocation detection features of HTML5?
center_on_user: true # centers map on the location detected through the browser
Google Chrome コンソールでこのエラーが発生しました。
キャッチされていない TypeError: 未定義の Gmaps4Rails.Gmaps4Rails.createImageAnchorPositiongmaps4rails.base.js:377 のプロパティ '0' を読み取れません Gmaps4RailsGoogle.Gmaps4RailsGoogle.createMarkergmaps4rails.googlemaps.js:127 (無名関数)
何が欠けていますか?? ありがとう
ステファン