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

fitBounds called before boundsObject initialized? #207

Closed kastman closed 12 years ago

kastman commented 12 years ago

Transferring from an SO question about the map not updating when manually setting bounds with @apneadiving :

When I provide a bounds in map_options, it appears that the fitBounds() in googlemaps is being called before the boundsObject is set, and is throwing an undefined/uninitialized error. I can't tell where it's called from, since I'm not a good coffeescript/js debugger and commenting out the @fitBounds() call in line 459 in adjustMapToBounds of base.coffee still calls fitBounds and raises the error. It looks like the boundsObject is correctly being set in adjustMapToBounds (I can see that with console.log)

this.serviceObject.fitBounds(this.boundsObject)(!this.boundsObject.isEmpty() ? {
application.js:10754 TypeError: 'undefined' is not an object (evaluating 'this.serviceObject.fitBounds')

When I call Gmaps.map.fitBounds() from the console after the map has loaded, the boundsObject has been defined, and it adjusts to the correct bounds.

Could you suggest a way to trace the call to figure out why it's being called early? Or am I misdiagnosing a simpler problem? Thanks for your help.

apneadiving commented 12 years ago

I'm sorry, I can't reproduce. Do you have some live page/repo I could check?

kastman commented 12 years ago

Thanks for checking; I'm traveling this weekend but will post a minimal example when I get back.

On May 12, 2012, at 7:48 AM, Benjamin Rothreply@reply.github.com wrote:

I'm sorry, I can't reproduce. Do you have some live page/repo I could check?


Reply to this email directly or view it on GitHub: https://github.com/apneadiving/Google-Maps-for-Rails/issues/207#issuecomment-5667848

kastman commented 12 years ago

Sorry, I haven't had time to put together a breaking example. I'll close this issue until I can get something up. Thanks for your patience, -Erik