<div>Hi all,<br></div><div></div><div>As before I'm having some problems with some of my GML layers. In particular, I'm trying to display three vector overlays, one of which is meant to be a dynamic POI, but that's another story. </div>
<div></div><div>The issue is this: Only one of my layers "sites" is displaying correctly. The topo layer only displays at all, and in the wrong place if I specify only the style option. If I specify the projection or format option with the same syntax as I do for the points layer, I can see in firebug that the layer get's loaded into the browser but if I set the map.getCenter function on the layer, it doesn't center at all, and zooms to what I assume is the max extent. </div>
<div></div><div>e.g.</div><div>//works</div><div>var topo = new OpenLayers.Layer.GML ("Topography", "data/topo.gml",<br> {<br> style: {strokeWidth: 1, strokeColor:"#CCCCCC"},<br> }<br> );<br>
</div><div></div><div>//doesn't </div><div>var topo = new OpenLayers.Layer.GML ("Topography", "data/topo.gml",<br> {<br> style: {strokeWidth: 1, strokeColor:"#CCCCCC"},<br> projection: new OpenLayers.Projection("EPSG:4326"),<br>
format: OpenLayers.Format.GML<br> }<br> );<br></div><div></div><div>I've stripped out the select controls and popups, and the script works, centers, and displays the one layer (sites) over wms baselayers correctly. Additionally, I've been trying to implement the layer.vector for the same layer as sites (sites2), which also get's loaded into the browser, but doesn't center if targeted by the map.getCenter function. Essentially, the same behavior as the quirky GML layers (i.e. get's loaded into the browser, but doesn't display or if it is displayed is not responsive to the map.getCenter function). I've tested each of these GML layers in ArcGIS and they display in the correct alignment. Additionally, the (sites) layer displays as Black seemingly without my having specified a color. Here is the bare minimum code of the script. I know this is kind of long, but I've added line breaks for clarity. As always, any help is greatly appreciated</div>
<div>best,</div><div>N</div>
<div></div><div>//</div><div>function init() {<br>                 map = new OpenLayers.Map ("map", <br>                                 {<br>                                 controls:[<br>                                 new OpenLayers.Control.Navigation(),<br>                                 new OpenLayers.Control.PanZoomBar(),<br>                                 new OpenLayers.Control.LayerSwitcher(),<br>
                                new OpenLayers.Control.Attribution()],<br>                         sphericalMercator: true,<br>                         maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br>                         maxResolution: 156543.0399,<br>                         numZoomLevels: 19,<br>
                        units: 'm',<br>                         projection: new OpenLayers.Projection("EPSG:900913"),<br>                         displayProjection: new OpenLayers.Projection("EPSG:4326"),<br>                                 }<br>                 );<br>          <br></div><div>                 var topo = new OpenLayers.Layer.GML ("Topography", "data/topo.gml",<br>
                {<br>                 projection: new OpenLayers.Projection("EPSG:4326"),<br>
                format: OpenLayers.Format.GML});<br>                 map.addLayer(topo);<br>          <br></div><div> var        sites = new OpenLayers.Layer.GML (<br>                 "Archaeological Sites", "data/siteswatr.gml",<br>                 {<br>                 style: {pointRadius: 2.5}, <br>
                projection: new OpenLayers.Projection("EPSG:4326"),<br>                 format: OpenLayers.Format.GML<br>                 }<br>                 );<br>         map.addLayer(sites);          <br>                 </div><div>var sites2 = new OpenLayers.Layer.Vector (<br>                 "sites2", {projection: map.displayProjection, strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({url: "data/siteswatr.gml", format: [new OpenLayers.Format.GML()]})});<br>
                map.addLayer(sites2);</div><div></div><div>                 if( ! map.getCenter() ){<br>                 sites.events.register('loadend', sites, function(){map.zoomToExtent(sites.getDataExtent())});<br>                 map.setCenter(null, null);<br>                 };<br>
<br></div>