2011-09-20 177 views
1

首先對不起我的英文,我在將一個kml文件(平鋪)放入openlayers時出現問題,使用此腳本生成谷歌地球的kml文件http://cimss.ssec.wisc.edu/imapp/dbge_v1.2.shtml,您可以看到一個示例在這裏:http://modis.umag.cl/desarrollo/kml/2011.09.18.1742.2_3/2011.09.18.1742.2_3.kml,它加載罰款谷歌地球,但我不知道該怎麼做,在的OpenLayers,我想這:在Openlayers中加載爲Google地球生成的KML瓷磚

var layer = new OpenLayers.Layer.Vector("KML", { 
      projection: map.displayProjection, 
      strategies: [new OpenLayers.Strategy.Fixed()], 
     protocol: new OpenLayers.Protocol.HTTP({ 
      url: "http://modis.umag.cl/desarrollo/kml/2011.09.18.1742.2_3/2011.09.18.1742.2_3.kml", 
      format: new OpenLayers.Format.KML({ 
       extractStyles: true, 
       extractAttributes: true, 
       maxDepth: 4 
      }) 
     }) 
    }) 

,但在地圖上沒有顯示,任何想法?謝謝。

回答

2

以下兩行添加到您的代碼:

layer.setVisibility(true);   
map.addLayer(layer); 

希望這有助於某位你收到錯誤請註明those.It幫助我們解決。