I'm setting some locations on the map in my website. I go to google maps and get co-ordinates of the places I want. Then I put these numbers into my longitude and latitude fields to position the marker. I check the map on my site and the markers are out by a small amount and I don't understand it.
I hold the values for longitude and latitude in floats.
this is the difference in location
Here is google maps
and this is where my marker is placed
you can see that its out by a good bit but I have put the longitude and latitude directly from google maps, so it should appear here.
here is my controller code
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
and here is the model code
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
I don't understand why my markers aren't falling in exactly the same place as google maps.
any help is very much appreciated, thanks.
Either:
use the latest version of the gem where default offset is null
or: handler = Gmaps.build('Google', { markers: { maxRandomDistance: null } });