apneadiving / Google-Maps-for-Rails

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

Marker showing up in slightly different location every time #427

Closed mstahl closed 10 years ago

mstahl commented 10 years ago

I'm not sure if this is a bug with Gmaps4rails or with Google Maps itself (so it would be really useful to know if anyone can reproduce this), but now that I have a map displaying on my page, it is in a slightly different location every time.

I have checked that the latitude and longitude are not changing in the model or in the javascript itself. Here's the Javascript as output to the page by the helper method I wrote:

<script>
  $(function () {
    var handler = Gmaps.build('Google');
    var gmaps_opts = {
      zoom: 15,
      zoomControl: false,
      center: new google.maps.LatLng(41.9385961, -87.64438249999999)
    };
    handler.buildMap({provider: gmaps_opts, internal: {id: 'map'}}, function() {
      var markers = handler.addMarkers([
        {
          "lat": 41.9385961,
          "lng": -87.64438249999999
        }
      ]);
    });
  });
</script>

( It's a somewhat modified version of what's on your README. )

This produces a map with a marker in any of three or four locations roughly centered around the general area I want the marker to be in, but without an exact location it's not particularly useful to have a map there.

screen shot 2014-02-06 at 5 29 09 pm screen shot 2014-02-06 at 5 29 19 pm

Is this happening for anyone else? How can I get exactly the code that gets called for this, so I can submit a bug report upstream to Google Maps?

apneadiving commented 10 years ago

http://stackoverflow.com/questions/20633640/google-maps-for-rails-location-floating-on-reload

I'm gonna change the default behavior in next release

mstahl commented 10 years ago

That's probably the right call :). Thanks!