2009-11-25 59 views

回答

1

我覺得OP想做的事,是通過類似於在默認訪問鷹眼/ LayerSwitcher一個按鈕來訪問他的自定義窗體的OpenLayers。

如何做到這一點可以從如何鷹眼控制*實現提取:

this.div.className += " " + this.displayClass + 'Container'; 
var imgLocation = OpenLayers.Util.getImagesLocation(); 
// maximize button div 
var img = imgLocation + 'layer-switcher-maximize.png'; 
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
         this.displayClass + 'MaximizeButton', 
         null, 
         new OpenLayers.Size(18,18), 
         img, 
         'absolute'); 
this.maximizeDiv.style.display = 'none'; 
this.maximizeDiv.className = this.displayClass + 'MaximizeButton'; 
OpenLayers.Event.observe(this.maximizeDiv, 'click', 
         OpenLayers.Function.bindAsEventListener(this.maximizeControl, 
                   this) 
); 
this.div.appendChild(this.maximizeDiv); 

// minimize button div 
var img = imgLocation + 'layer-switcher-minimize.png'; 
this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
         'OpenLayers_Control_minimizeDiv', 
         null, 
         new OpenLayers.Size(18,18), 
         img, 
         'absolute'); 
this.minimizeDiv.style.display = 'none'; 
this.minimizeDiv.className = this.displayClass + 'MinimizeButton'; 
OpenLayers.Event.observe(this.minimizeDiv, 'click', 
OpenLayers.Function.bindAsEventListener(this.minimizeControl, 
             this) 
); 
this.div.appendChild(this.minimizeDiv); 

var eventsToStop = ['dblclick','mousedown']; 

for (var i=0, len=eventsToStop.length; i<len; i++) { 
    OpenLayers.Event.observe(this.maximizeDiv, 
          eventsToStop[i], 
          OpenLayers.Event.stop); 

    OpenLayers.Event.observe(this.minimizeDiv, 
          eventsToStop[i], 
          OpenLayers.Event.stop); 
} 

*:取自文件:的OpenLayers/lib中/的OpenLayers /控制/ OverviewMap.js

插入並修改這個,可以用來創建我認爲你正在尋找的效果。

祝你好運!

+0

感謝您的回答 – ricardo 2010-02-08 15:46:45