<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I was able to work around this by adding a custom field to the layer initializer and using Map.getLayersBy() instead of Map.getLayer() when I want to get a reference to the layer.<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF391171" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> openlayers-users-bounces@lists.osgeo.org [openlayers-users-bounces@lists.osgeo.org] on behalf of Ruff, Thomas [Thomas.Ruff@solers.com]<br>
<b>Sent:</b> Thursday, May 22, 2014 2:39 PM<br>
<b>To:</b> openlayers-users@lists.osgeo.org<br>
<b>Subject:</b> [OpenLayers-Users] can't supply id to vector layer<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<div id="divRpF336411" style="direction:ltr"><span style="font-family:monospace">In OL 2.13.1 I'm getting this error: </span></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
<div><span style="font-family:monospace; font-size:16px">"TypeError: this.container is null" in OpenLayers.debug.js (line 57513)</span></div>
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
<div><span style="font-family:monospace; font-size:16px">whenever I supply an id property to my Vector layer during construction.  If I don't set an id on the layer everything works fine, but I want to use the id to find the layer later.  The layer is being
 added dynamically as shown below. </span></div>
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
<div>
<div><font face="monospace" size="3">var icaoLayer = new OpenLayers.Layer.Vector('myFeature', {</font></div>
<div><font face="monospace" size="3">    strategies: [new OpenLayers.Strategy.Fixed()],</font></div>
<div><font face="monospace" size="3">    id: 'myFeatureId',</font></div>
<div><font face="monospace" size="3">    protocol: new OpenLayers.Protocol.WFS({</font></div>
<div><font face="monospace" size="3">        url: '/server/wfs',</font></div>
<div><font face="monospace" size="3">        version: '1.1.0',</font></div>
<div><font face="monospace" size="3">        featureType: 'myFeatureType',</font></div>
<div><font face="monospace" size="3">        featureNS: 'namespace',</font></div>
<div><font face="monospace" size="3">        srsName: 'EPSG:4326',</font></div>
<div><font face="monospace" size="3">        outputFormat: 'json',</font></div>
<div><font face="monospace" size="3">        maxFeatures: 1</font></div>
<div><font face="monospace" size="3">    }),</font></div>
<div><font face="monospace" size="3">    filter: new OpenLayers.Filter.Comparison({</font></div>
<div><font face="monospace" size="3">        type: OpenLayers.Filter.Comparison.EQUAL_TO,</font></div>
<div><font face="monospace" size="3">        property: 'stationid',</font></div>
<div><font face="monospace" size="3">        value: stationId</font></div>
<div><font face="monospace" size="3">    }),</font></div>
<div><font face="monospace" size="3">    visibility: true</font></div>
<div><font face="monospace" size="3">});</font></div>
<div><font face="monospace" size="3"><br>
</font></div>
<div><font face="monospace" size="3">icaoLayer.events.register('loadend', icaoLayer, function (evnt) {</font></div>
<div><font face="monospace" size="3">    var zoomLevel = 11;</font></div>
<div><font face="monospace" size="3">    openLayersMap.moveTo(new OpenLayers.LonLat(evnt.response.features[0].geometry.x, evnt.response.features[0].geometry.y), zoomLevel);</font></div>
<div><font face="monospace" size="3">});</font></div>
<div><font face="monospace" size="3">openLayersMap.addLayer(icaoLayer);</font></div>
</div>
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
<div><span style="font-family:monospace; font-size:16px">Is there something wrong with my code?  </span><span style="font-family:monospace; font-size:16px">This seems like a bug but I wanted to ask here before entering it.</span></div>
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
<div><span style="font-family:monospace; font-size:16px">Thanks,</span></div>
<div><span style="font-family:monospace; font-size:16px">Tom </span></div>
<div><br>
</div>
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
<div><span style="font-family:monospace; font-size:16px"><br>
</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>