2013-11-22 1 views
1

나는 중국에있는 학생입니다. gmap4rails gem을 사용할 때 나는 한 가지 문제가 있습니다. 나는 마오 센터를 설정하고 공식 가이드 제안처럼 확대하고 싶습니다.
https://developers.google.com/maps/documentation/javascript/tutorial?#HelloWorld 그래서 나는 그림 쇼처럼 코드합니다.하지만 작동하지 않습니다. 그리고 Google은 질문을했지만 대답을 얻지 못했습니다. 무엇보다, 나는 중국어로 언어를 설정하고 싶습니다. 이처럼 좋아하지만 작동하지 않습니다.gmap4rails에서지도 중심 및 위성을 설정하는 방법

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

나를 도울 수 있습니까?

답변

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 
}); 

또는를 :

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); 
}); 

그것은 id 당신이지도를 표시 할 div의 통과하는 것이 중요합니다.

관련 문제