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

Map don't display #213

Closed chartrandf closed 12 years ago

chartrandf commented 12 years ago

Hi, I don't know why but I can display the map on my view. The HTML is there, but it 's display only a blank field with borders. I've follow everythings, step by step.

My settings:

  acts_as_gmappable :lat => 'latitude', :lng => 'longitude', :process_geocoding => :geocode?,
                    :address => "street", :normalized_address => "street",
                    :msg => "Sorry, not even Google could figure out where that is"

  def geocode?
    !(street.blank? || (!latitude.blank? && !longitude.blank?))
  end

  def gmaps4rails_address
    street
  end

Controller

    @json = Address.all.to_gmaps4rails

View.html

   = gmaps4rails(@json)

I've included gmaps4rails.css and I have in my footer yield :scripts

apneadiving commented 12 years ago

any js error?

a public url so that I can check?

chartrandf commented 12 years ago

Oups I forgot to chek this. Yep I got one => Gmaps is not defined. No public url for the moment, but if I can't solve it I can deploy it.

Loaded scripts:

//maps.google.com/maps/api/js?v=3.8&sensor=false&key=&libraries=geometry&language=&hl=&region= //google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js

<script type="text/javascript" charset="utf-8">
Gmaps.map = new Gmaps4RailsGoogle();
Gmaps.load_map = function() {
Gmaps.map.map_options.auto_adjust = true;
Gmaps.map.initialize();
Gmaps.map.markers = [{"lat":46.8554,"lng":-71.2542},{"lat":46.8078,"lng":-71.2438},{"lat":46.821,"lng":-71.3291},{"lat":46.8582,"lng":-71.3356},{"lat":46.8467,"lng":-71.3264},{"lat":46.8696,"lng":-71.2664},{"lat":46.7942,"lng":-71.2517},{"lat":46.9032,"lng":-71.1902},{"lat":46.8533,"lng":-71.2106},{"lat":46.8532,"lng":-71.2313},{"lat":46.8834,"lng":-71.2858},{"lat":46.8899,"lng":-71.2108},{"lat":46.8905,"lng":-71.1994},{"lat":46.868,"lng":-71.2895},{"lat":46.8032,"lng":-71.2493},{"lat":46.891,"lng":-71.1934},{"lat":46.9117,"lng":-71.1975},{"lat":46.8386,"lng":-71.2217},{"lat":46.8181,"lng":-71.2228},{"lat":46.8107,"lng":-71.2365},{"lat":46.7938,"lng":-71.2565},{"lat":46.8105,"lng":-71.3214},{"lat":46.7962,"lng":-71.242},{"lat":46.8712,"lng":-71.2809},{"lat":46.8567,"lng":-71.3332},{"lat":46.8737,"lng":-71.1757},{"lat":46.842,"lng":-71.3065},{"lat":46.8129,"lng":-71.2633},{"lat":46.847,"lng":-71.2556},{"lat":46.8061,"lng":-71.2282},{"lat":46.8017,"lng":-71.2358},{"lat":46.8182,"lng":-71.2361},{"lat":46.8135,"lng":-71.2818},{"lat":46.8146,"lng":-71.3153},{"lat":46.8319,"lng":-71.2297},{"lat":46.8988,"lng":-71.3064},{"lat":46.8296,"lng":-71.3162},{"lat":46.8717,"lng":-71.1911},{"lat":46.8886,"lng":-71.1625},{"lat":46.8591,"lng":-71.2099},{"lat":46.8767,"lng":-71.2437},{"lat":46.812,"lng":-71.2416},{"lat":46.8586,"lng":-71.1899},{"lat":46.8326,"lng":-71.3466},{"lat":46.858,"lng":-71.4204},{"lat":46.8154,"lng":-71.3145},{"lat":46.8129,"lng":-71.2044},{"lat":46.8547,"lng":-71.3629},{"lat":46.8512,"lng":-71.3601},{"lat":46.8126,"lng":-71.3203},{"lat":46.8467,"lng":-71.3264},{"lat":46.8424,"lng":-71.2244},{"lat":46.8181,"lng":-71.2228},{"lat":46.8375,"lng":-71.2411},{"lat":46.8054,"lng":-71.2472},{"lat":46.8006,"lng":-71.2264},{"lat":46.8053,"lng":-71.2055},{"lat":46.8364,"lng":-71.2158},{"lat":46.9053,"lng":-71.1902},{"lat":46.8529,"lng":-71.2346},{"lat":46.8364,"lng":-71.2158},{"lat":46.8375,"lng":-71.2411},{"lat":46.845,"lng":-71.2283},{"lat":46.8423,"lng":-71.3059},{"lat":46.8472,"lng":-71.3086},{"lat":46.8723,"lng":-71.3347},{"lat":46.7971,"lng":-71.2394},{"lat":46.8683,"lng":-71.2895},{"lat":46.8187,"lng":-71.3095},{"lat":46.8117,"lng":-71.323},{"lat":46.8116,"lng":-71.2373},{"lat":46.821,"lng":-71.2236},{"lat":46.8251,"lng":-71.2615},{"lat":46.8156,"lng":-71.2817},{"lat":46.8472,"lng":-71.3086},{"lat":46.813,"lng":-71.2682},{"lat":46.9059,"lng":-71.3005},{"lat":46.7607,"lng":-71.3208},{"lat":46.8833,"lng":-71.1597},{"lat":46.7635,"lng":-71.283},{"lat":46.7841,"lng":-71.2958},{"lat":46.7664,"lng":-71.3062},{"lat":46.7408,"lng":-71.3556},{"lat":46.7868,"lng":-71.2509},{"lat":46.8332,"lng":-71.3596},{"lat":46.8652,"lng":-71.2703},{"lat":46.7872,"lng":-71.2661},{"lat":46.8461,"lng":-71.2508},{"lat":46.8594,"lng":-71.1925},{"lat":46.8355,"lng":-71.3432},{"lat":46.8214,"lng":-71.2416},{"lat":46.8145,"lng":-71.3153},{"lat":46.7871,"lng":-71.2674},{"lat":46.8304,"lng":-71.3215},{"lat":46.7635,"lng":-71.283},{"lat":46.7868,"lng":-71.267},{"lat":46.7553,"lng":-71.3098},{"lat":46.7874,"lng":-71.2666},{"lat":46.8449,"lng":-71.2248},{"lat":46.8578,"lng":-71.1889},{"lat":46.888,"lng":-71.1723},{"lat":46.8767,"lng":-71.2437}];
Gmaps.map.markers_conf.do_clustering = true;
Gmaps.map.create_markers();
Gmaps.map.adjustMapToBounds();
Gmaps.map.callback();
};
Gmaps.oldOnload = window.onload;
 window.onload = function() { Gmaps.triggerOldOnload(); Gmaps.loadMaps(); };
</script>
apneadiving commented 12 years ago

Gmaps not defined means (1) the js files are not included in your page or (2) Gmaps is called before they are included.

(1) you've the yield :scripts in your layout so it should be good

(2) do you have any call to the js Gmaps namespace in your view? Paste the whole html in a gist please

chartrandf commented 12 years ago

https://gist.github.com/2764782 (2) I don't think so

apneadiving commented 12 years ago

Did you run:

 rails generate gmaps4rails:install

Do you have the gmaps js files in your asset pipeline?

chartrandf commented 12 years ago

Yes I have run this command.

My asset pipeline structure looks like:

But any of these files are included in my HTML, I propably should include one?

chartrandf commented 12 years ago

Ahhhh got it!! :) Thanks you for your support, very helpful !!!

apneadiving commented 12 years ago

Good news :)