2

I'm new to openLayers and trying to add a GML overlay:

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

The file renders perfectly as is in Chrome and Safari, but doesn't render at all in Firefox or IE; only the underlying Google layers. It's in the same directory as the HTML page. Nothing I try seems to work. Here's the code in question:

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

What could be causing the problem, and can it be fixed?

Rob
  • 4,927
  • 4
  • 26
  • 41
J.P. Kirby
  • 21
  • 2
  • I tried to resolve your problem, but did not find a fix, but I found out that there might be something wrong with your .gml file. See here: http://www.validome.org/xml/validate/?lang=en&url=http://the506.com/elxnmaps/2011/13003test.gml Can you generate a new one or fix this and try again? – Martin Dec 13 '12 at 17:23

1 Answers1

0

When I test, it looks like your poll-by-poll layer loads successfully in Chrome/Firefox. However, there's a syntax error on line 8 of your stylemap.js:

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

Remove the comma and try to reload in IE.

Kyle
  • 4,202
  • 1
  • 33
  • 41