Rais 4.0.4
gem geocoder =>(1.1.9)
gem gmaps4rails =>(2.1.1)
db table
:latitude, :float
:longitude, :float
嗨!每次我保存纬度'和经度'属性进入db保存的数据略有不同或完全不同。例如:
示例:13 Rue Jules-Verne,蒙特利尔,QC: 纬度:45.507147 经度:-75.63314
https://maps.google.ca/maps?q=13+Rue+Jules-Verne,+Montreal,+QC&hl=en&sll=45.507147,-75.63314&sspn=0.007925,0.019741&oq=13,+rue+Jules-Verne+mo&hnear=13+Rue+Jules-Verne,+Montreal,+Quebec+H2R&t=m&z=16
提交:
Started PATCH "/reuniones/493" for 127.0.0.1 at 2014-04-07 14:18:38 -0400
Processing by ReunionesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"v48VTm37AIo5VuJeBVqVPmSDV51gWBYO5M5EtnDVc+c=", "reunione"=>{"name"=>"CENTRAL HISPANO", "day"=>"domingo", "start_time(1i)"=>"2000", "start_time(2i)"=>"1", "start_time(3i)"=>"1", "start_time(4i)"=>"19", "start_time(5i)"=>"00", "address"=>"13, rue Jules-Verne", "suburb"=>"Montréal, QC ", "city"=>"Montréal", "postal_code"=>"H2R 1W8", "metro"=>"Métro De Castelnau", "public"=>"1", "district"=>"District 32", "genre"=>"Conferenciante", "latitude"=>"45.50714", "longitude"=>"-75.63314"}, "commit"=>"Submit", "id"=>"493"}
Reunione Load (0.4ms) SELECT "reuniones".* FROM "reuniones" WHERE "reuniones"."id" = $1 ORDER BY reuniones.day LIMIT 1 [["id", "493"]]
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1
(0.1ms) BEGIN
(0.1ms) COMMIT
Redirected to http://0.0.0.0:3000/reuniones/493
Completed 302 Found in 358ms (ActiveRecord: 1.0ms)
取回:
Reunione.find 493
<Reunione id: 493, [...other field ... ] latitude: 47.3515171, longitude: -2.181469>
答案 0 :(得分:1)
您使用的lat long值可能与您提交的地址不同。地理编码器获取一个地址并将其转换为lat long,这可能会覆盖lat而不是你的总和