2011-04-18 68 views
1

我已經安裝了甜美的Google-Maps-for-Rails插件,這似乎正在積極開發之中。任何人都知道如何更改Google-Maps-for-Rails地圖的尺寸​​

現在,我想弄清楚如何刪除谷歌控制和更改地圖的大小。有良好的文檔here開始,但我無法找到如何做這件簡單的事情。我能夠進入CSS文件並更改div的寬度,但這是脆弱的,而不是我認爲作者所期望的。

功能負荷:

 
window.onload = function() {Gmaps4Rails.map_options.auto_adjust = true;Gmaps4Rails.initialize();Gmaps4Rails.markers = [{"description": "", "title": "", "sidebar": "","longitude": "-77.0934", "latitude": "38.8115", "picture": "", "width": "", "height": ""} ];Gmaps4Rails.create_markers();} 

所以它似乎是一個天然的選擇。任何幫助不勝感激。

回答

1

這是很容易實現的GoogleMaps即使不使用插件。 基本上所有你需要做的是包括gmaps JavaScript中的頭:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 

和初始化函數:

function initGmaps() { 
var latlng = new google.maps.LatLng(48.839234,12.969335); // to be replaced with desired latitide/langitude 
var myOptions = { 
    zoom: 16, 
    mapTypeId: google.maps.MapTypeId.ROADMAP, 
    center: latlng 
}; 
var myMap = new google.maps.Map(document.getElementById("gmaps"), myOptions); 

var marker = new google.maps.Marker({ 
    position: latlng, 
    map: myMap, 
    title:"marker title" 
});  

}

和你做。

寬度和高度將由所選div的css指定,在本例中爲#gmaps。

+0

我想我可能會這樣 - 谷歌地圖插件太重,對我來說不靈活 – bonhoffer 2011-04-20 10:41:12

相關問題