如何在gmap4rails中设置地图中心和zoon

1 ruby-on-rails gmaps4rails

我是中国的学生.并使用gmap4rails宝石时,我有一个疑难问题.要设置的茂中心和缩放一样,官方指导报价
https://developers.google.com/maps/documentation/javascript/tutorial?#HelloWorld 所以像我的代码图片显示.但它不起作用.谷歌的问题,但没有得到答案.更多的是,我想把语言设置为中文我喜欢这样做,但它没有用.

var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8
};
handler = Gmaps.build('Google',mapOptions);
Run Code Online (Sandbox Code Playgroud)

你能帮助我吗?

apn*_*ing 7

你应该做:

var mapOptions = {
  center: new google.maps.LatLng(-34.397, 150.644),
  zoom: 8
};
handler = Gmaps.build('Google');
handler.buildMap( {provider: mapOptions, internal: {id: 'map'}}, function(){
  //code to add overlays etc... here
});
Run Code Online (Sandbox Code Playgroud)

要么:

handler = Gmaps.build('Google');
handler.buildMap( {internal: {id: 'map'}}, function(){
  // handler.map is the proxy object created by the gem, 
  // where you can add your custom methods,
  // like centerOn
  handler.map.centerOn([-34.397, 150.644]);

  // handler.getMap() is the google map object
  // you can also access it with handler.map.getServiceObject()
  handler.getMap().setZoom(8);
});
Run Code Online (Sandbox Code Playgroud)

传递您希望地图显示iddiv位置非常重要.