[OpenLayers-Users] Issues with layers

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Mon Aug 3 23:16:45 EDT 2009


Hi all,
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.
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.
e.g.
//works
var topo = new OpenLayers.Layer.GML ("Topography", "data/topo.gml",
  {
  style: {strokeWidth: 1, strokeColor:"#CCCCCC"},
  }
  );
//doesn't
var topo = new OpenLayers.Layer.GML ("Topography", "data/topo.gml",
  {
  style: {strokeWidth: 1, strokeColor:"#CCCCCC"},
  projection: new OpenLayers.Projection("EPSG:4326"),
  format: OpenLayers.Format.GML
  }
  );
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
best,
N
//
function init() {
  map = new OpenLayers.Map ("map",
  {
  controls:[
  new OpenLayers.Control.Navigation(),
  new OpenLayers.Control.PanZoomBar(),
  new OpenLayers.Control.LayerSwitcher(),
  new OpenLayers.Control.Attribution()],
  sphericalMercator: true,
  maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
  maxResolution: 156543.0399,
  numZoomLevels: 19,
  units: 'm',
  projection: new OpenLayers.Projection("EPSG:900913"),
  displayProjection: new OpenLayers.Projection("EPSG:4326"),
  }
  );

  var topo = new OpenLayers.Layer.GML ("Topography", "data/topo.gml",
  {
  projection: new OpenLayers.Projection("EPSG:4326"),
  format: OpenLayers.Format.GML});
  map.addLayer(topo);

  var sites = new OpenLayers.Layer.GML (
  "Archaeological Sites", "data/siteswatr.gml",
  {
  style: {pointRadius: 2.5},
  projection: new OpenLayers.Projection("EPSG:4326"),
  format: OpenLayers.Format.GML
  }
  );
  map.addLayer(sites);

var sites2 = new OpenLayers.Layer.Vector (
  "sites2", {projection: map.displayProjection, strategies: [new
OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({url:
"data/siteswatr.gml", format: [new OpenLayers.Format.GML()]})});
  map.addLayer(sites2);
  if( ! map.getCenter() ){
  sites.events.register('loadend', sites,
function(){map.zoomToExtent(sites.getDataExtent())});
  map.setCenter(null, null);
  };
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090804/aaac1245/attachment.html


More information about the Users mailing list