I am using Gmaps4rails. It's working really fine. But now I got an issue in trying geolocate my user via the browser.
My view:
<%= 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 %>
I tried a setinterval method for the browser geolocation delay as discussed in How do I display the user's location with a marker in gmaps4rails?
my gmaps coffee script
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
I got this error in my google chrome console.
Uncaught TypeError: Cannot read property '0' of undefined Gmaps4Rails.Gmaps4Rails.createImageAnchorPositiongmaps4rails.base.js:377 Gmaps4RailsGoogle.Gmaps4RailsGoogle.createMarkergmaps4rails.googlemaps.js:127 (anonymous function)
What am I missing ?? Thanks
Stephane