apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Markers not showing up on bing #250

Closed joshco closed 10 years ago

joshco commented 12 years ago

Code: (this works fine on google) <%= gmaps("markers" => {"data" => @json, "options" => {"list_container" => "markers_list"}},

      "map_options" => {"auto_zoom" => true,
                              "provider" => "bing",
                                 "provider_key" => 'AjKwa-JejepRZFgx8ldsdOfIQWvDXJwE9QhYLXMFTTaYsCNGd5mi71xcobzmS6BE',
              #google key AIzaSyAUIUBq-SgcwHvjhb3bT_szJlUHGOeDQk0
                        "auto_adjust" => true,
                        "detect_location" => true,
                        "center_on_user" => true
      }) %>

Screen shot of map and my marker json http://splitatom.com/gmaps4railsbing.png

apneadiving commented 12 years ago

Sorry I don't understand: there is a marker on your map.

joshco commented 12 years ago

That's not a real marker. If you look at the JSON near the bottom of the image, you'll see that there are two markers passed to gmaps4rails. Neither show up. The map image renders and the marker icon shows up in the middle of the image, no matter where you pan to. (it's not connected to any location) It isn't paying attention to what is coming in with the JSON marker list.

Dahie commented 11 years ago

I just came across the same issue. This behavior happens when the markers-array is generated using the #to_gmaps4rails action. eg:

@json = Model.all.to_gmaps4rails

The resulting array has the lon and lat value encoded as float, not as string, as provided in the example in the wiki: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Markers Once you change this manually to string datatype, the markers are positioned correctly and don't reposition every time the map moves.