2012-12-12 25 views
2

我是新來的OpenLayers不渲染,並嘗試添加GML覆蓋:的OpenLayers:矢量層在某些瀏覽器

http://the506.com/elxnmaps/2011/ftontest.html

文件呈現完美地在Chrome和Safari,但不在Firefox或IE中完全渲染;只有基礎的Google圖層。它與HTML頁面位於同一目錄中。沒有我嘗試似乎工作。這裏的代碼有問題:

function init(){ 
      map = new OpenLayers.Map('map', { 
      projection: 'EPSG:3857', 
      layers: [(Google layers)], 
      center: new OpenLayers.LonLat(-66.6, 46.0).transform('EPSG:4326', 'EPSG:3857'), 
      zoom: 10 
}); 
    map.addControl(new OpenLayers.Control.LayerSwitcher()); 

    (styling rules) 

var kmllayer = new OpenLayers.Layer.Vector("Poll-by-Poll Data", { 
      protocol: new OpenLayers.Protocol.HTTP({ 
       url: './13003test.gml', 
       format: new OpenLayers.Format.GML({extractAttributes: true}) 
      }), 
      strategies: [new OpenLayers.Strategy.Fixed()], 
    visibility: true, 
    styleMap: new OpenLayers.StyleMap(style), 
    projection: new OpenLayers.Projection('EPSG:4326') 
     }); 

    map.addLayer(kmllayer); 

     selectControl = new OpenLayers.Control.SelectFeature(kmllayer, 
      {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}); 

     map.addControl(selectControl); 
     selectControl.activate() 
    } 

什麼可能導致的問題,它可以修復?

+0

我試着解決你的問題,但沒有找到解決辦法,但是我發現你的.gml文件可能有問題。看到這裏:http://www.validome.org/xml/validate/?lang=en&url=http://the506.com/elxnmaps/2011/13003test.gml 你可以生成一個新的或修復這個並嘗試再次? – Martin

回答

0

當我測試時,它看起來像你的輪詢輪詢層在Chrome/Firefox中成功加載。但是,stylemap.js的第8行存在語法錯誤:

var main = new OpenLayers.Style(
{ 
    fillOpacity: 0.55, 
    strokeWidth: 0.4, 
    strokeOpacity: 0.9, 
    pointRadius: 2, 
    strokeColor: "#aaaaaa", // no comma here 
}... 

刪除逗號並嘗試在IE中重新加載。

相關問題