我在 Rails 3.1.3 应用程序中使用 gmaps4rails,我在 gmaps4rails.base.js.coffee 文件中设置了位置检测,如下所示;
@default_map_options =
id: 'map'
draggable: true
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
center_latitude: 0
center_longitude: 0
zoom: 7
maxZoom: null
minZoom: 10
auto_adjust : true # adjust the map to the markers if set to true
auto_zoom: true # zoom given by auto-adjust
bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
raw: {} # raw json to pass additional options
这有一半的时间。我注意到当我按 F5 或 Ctrl+r 刷新浏览器时,它有时会将我置于 Broken Hill,而我应该在墨尔本(相差 840 公里)。
有时我看到它很快就去了布罗肯希尔,然后在装载时切换到墨尔本。以下是我安装的所有其他插件:
#= require gmaps4rails/gmaps4rails.base
#= require gmaps4rails/gmaps4rails.googlemaps
#= require jquery
#= require jquery_ujs
#= require jquery.ui.datepicker
#= require jquery-ui-timepicker-addon
#= require jquery.ui.autocomplete
#= require jquery.ui.slider
#= require jquery.flexslider
#= require jquery.ui.widget
#= require jquery.ui.mouse
#= require jquery.ui.touch-punch.min
#= require jQuery.BlackAndWhite
#= require form-accordion
#= require modernizr
#= require lovesjavascript
#= require jquery.tokeninput
#= require authentications
#= require inquiries
#= require registrations
#= require search
#= require tinymce-jquery
#= require jquery.sticky
#= require_self
我只尝试了 gmaps4rails base & googlemaps,但仍然有问题。