Search code examples
google-mapsgoogle-maps-api-3gmaps4rails

Markers for Google maps not in right spot


I have created a google map using the google maps for rails gem. I am using custom svg markers.

The markers are not appearing over the proper location (see Dallas or Chicago in attached image).

In my controller I have created a hash object. I have tried to adjust the marker's position with the marker_anchor property, but it doesn't appear to have any effect on the position of the image on the map. I also tried using the int 1-9 format or richmarker (ie [1, true]) but this did not work either.

@hash = Gmaps4rails.build_markers(@cities_for_map) do |city, marker|
  marker.lat city.latitude
  marker.lng city.longitude
  marker.picture({
    "url" => "/images/maps/regular.marker.svg",
    "width" => 13,
    "height" => 13,
    "marker_anchor" => [0, 50]
  })
  marker.infowindow render_to_string(:partial => "/destinations/map_tile.html", :locals => { :city => city})
end

Am I trying to modify the wrong property or is their a bug with the gem?

enter image description here


Solution

  • @apneadiving solved this

    Use need to use anchor, not marker_anchor. I assumed that I was using the richmarker library out of the box.