开发者

How to initialize at js new map in gmaps4rails 1.3.0

I am trying by this example: link initialize the seckond map by clicking ajax button but map is not initialized. I working on latest version gmaps4rails. My source:

= gmaps("map_options" => { "detect_location" => true, "center_on_user" => 开发者_如何学运维true, "auto_adjust" => true, "zoom" => 12, "auto_zoom" => false })

%button#ajax_map Ajax Map

#map_container
  #map2

js:

$(function() {
  $('#ajax_map').click(function(){
    $('#map_container').addClass('map_container');
    $('#map2').addClass('gmaps4rails_map');
    Gmaps.map2.map_options.detect_location = true;
    Gmaps.map2.map_options.center_on_user = true;
    Gmaps.map2.initialize();
  });
});

css:

.map_container {
  width: 600px;
}

#map {
  width: 600px;
  height: 400px;
}
#map2 {
  width: 600px;
  height: 400px;
}

What am I doing wrong?


Since 1.0.0, I create 'real' js objects.

So you need to instantiate it:

Gmaps.map2 = new Gmaps4RailsGoogle(); // for a google map
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜