使用gmaps4rails我的long和lat有点不合适,我不知道为什么

时间:2014-03-12 15:56:22

标签: ruby-on-rails ruby-on-rails-3 gmaps4rails

我在网站上的地图上设置了一些位置。我去谷歌地图,并得到我想要的地方的坐标。然后我将这些数字放入我的经度和纬度字段以定位标记。我检查了我网站上的地图,标记很少,我不明白。

我在浮点数中保存经度和纬度的值。

这是位置上的差异

这是谷歌地图 enter image description here

这就是我的标记放置的位置 enter image description here

你可以看到它的位置很好,但我已经直接从谷歌地图中放置了经度和纬度,所以它应该出现在这里。

这是我的控制器代码

def show
@store = Store.all
@json = Store.all.to_gmaps4rails do |store, marker|
  marker.infowindow render_to_string(:partial => "/stores/infowindow", :locals => { :store => store})
  marker.json ({:title => store.title})
  marker.json ({:latitude => store.latitude})
  marker.json ({:longitude => store.longitude})
  marker.json ({:street_line_one => store.street_line_one})
  marker.json ({:street_line_two => store.street_line_two})
  marker.json ({:town => store.town})
  marker.json ({:county => store.county})
  marker.json ({:opening_hours=>store.opening_hours})
  marker.json ({:phone_no=>store.phone_no})
  marker.json ({:email=>store.email})
  marker.picture ({
    'picture'=>view_context.image_path("map_marker.png"),
    'width'=>79,
    'height'=>74
    })
end

这是模型代码

class Store < ActiveRecord::Base
  acts_as_gmappable

  attr_accessible :id, :street_line_one, :latitude, :longitude, :street_line_two, :town, :county, :country, :gmaps, :title, :opening_hours, :mainpage_images, :phone_no, :email

  def gmaps4rails_address
      "#{latitude}, #{longitude}"
  end
end

我不明白为什么我的标记与谷歌地图完全不同。

非常感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分:1)

或者:

  • 使用gem的最新版本,其中default offset为null

  • 或:handler = Gmaps.build('Google', { markers: { maxRandomDistance: null } });