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

ReferenceError: Can't find variable: MarkerClusterer #158

Closed romanenko closed 12 years ago

romanenko commented 12 years ago

First of all, thanks for great work. It is a great gem I really enjoy to use.

After updating to 1.4.6 from 1.4.5 strange js error appears

ReferenceError: Can't find variable: MarkerClusterer
gmaps4rails.googlemaps.js:229

I tried to regenerate with rails generate gmaps4rails:install command, but it didn't help. Falling back to 1.4.5 saving the situation.

I use Rails 3.2.2 in my project, Safari 5.1.3 as a browser.

apneadiving commented 12 years ago

Do you pass :do_clustering => true in map_options?

Sent from my iPhone

On 10 mars 2012, at 18:30, Michael Romanenkoreply@reply.github.com wrote:

First of all, thanks for great work. It is a great gem I really enjoy to use.

After updating to 1.4.6 from 1.4.5 strange js error appears

ReferenceError: Can't find variable: MarkerClusterer gmaps4rails.googlemaps.js:229

I tried to regenerate with rails generate gmaps4rails:install command, but it didn't help. Falling back to 1.4.5 saving the situation.

I use Rails 3.2.2 in my project, Safari 5.1.3 as a browser.


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

romanenko commented 12 years ago

No, I don't.

But, maybe this is because I do pass data: false:

    <%= gmaps(HashWithIndifferentAccess.new(:markers => {:data => false }, "map_options" => {:raw => '{ panControl: false, zoomControl: false, mapTypeControl: false, scaleControl: false, 
    streetViewControl: false, overviewMapControl: false}', :libraries => ["places", "overlays"], "auto_zoom" => false, "auto_adjust" => false, :zoom => 10, :minZoom => 10, 
    "center_longitude" => 74.5879, "center_latitude" => 42.87} )) %> 
apneadiving commented 12 years ago

Mmm, I decided to remove the load of all js libraries when they aren't really needed.

I fear I forgot to remove a configuration parameter in the js.

I'll fix it soon, thanks for reporting!

Sent from my iPhone

On 10 mars 2012, at 18:49, Michael Romanenkoreply@reply.github.com wrote:

No, I don't.

But, maybe this is because I do pass data: false:

   <%= gmaps(HashWithIndifferentAccess.new(:markers => {:data => false }, "map_options" => {:raw => '{ panControl: false, zoomControl: false, mapTypeControl: false, scaleControl: false, 
   streetViewControl: false, overviewMapControl: false}', :libraries => ["places", "overlays"], "auto_zoom" => false, "auto_adjust" => false, :zoom => 10, :minZoom => 10, 
   "center_longitude" => 74.5879, "center_latitude" => 42.87} )) %>

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

apneadiving commented 12 years ago

Ok, issue corrected in 1.4.7

Thanks again,

Ben

On Mar 10, 2012, at 6:49 PM, Michael Romanenko wrote:

No, I don't.

But, maybe this is because I do pass data: false:

  <%= gmaps(HashWithIndifferentAccess.new(:markers => {:data => false }, "map_options" => {:raw => '{ panControl: false, zoomControl: false, mapTypeControl: false, scaleControl: false, 
  streetViewControl: false, overviewMapControl: false}', :libraries => ["places", "overlays"], "auto_zoom" => false, "auto_adjust" => false, :zoom => 10, :minZoom => 10, 
  "center_longitude" => 74.5879, "center_latitude" => 42.87} )) %>

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

daffydowden commented 12 years ago

Is this issue definitely resolved? As I have the same problem on 1.4.8. My code was working on 1.3.2, and works on 1.4.5, but breaks on 1.4.6, 1.4.7 and 1.4.8.

I tried poking around in the file /app/views/gmaps4rails/_scripts.html.erb and tried to print out the value of map_options but it only every returned nil. Do I now have to pass :do_clustering => true for every call of gmap()? I have this set in a constructor, but I'm not sure whether this is the correct method to set this globally or not?

class @Gmaps4Rails 
  constructor: ->
    ...
    @default_markers_conf = 
       ...
       do_clustering: true
apneadiving commented 12 years ago

I decided to remove the auto inclusion of js files: it was dirty to include everything all the time.

Your patch would work if you include the markerclusterer js file in your view.

A better option would be to override the helper method and pass the 'do_clustering' automatically: everything will be handled by the gem this way.