<div>I have a vector layer populated with some multipolygons. I use a php frontend to query a postgis database for necessary shapes, and initialize the reader with the statement</div><div><br></div><div>var parcer = new OpenLayers.Format.WKT();</div>
<div><br></div><div>I then populate the layer with multimple statements like</div><div>var polygon0 = parcer.read("MULTIPOLYGON(((-8529098.94304024 4765383.48913123</div><div>blah, blah blah.</div><div>The multipolygon statements being encoded into the javascript as the page is being built by php.</div>
<div><br></div><div>Everything works well. So far.</div><div><br></div><div>Now, after the page is loaded the user has opportunity to query that same postgis database and get more shapes. I use a php backend to serve up JSONs for each query, and firebug tells me that the WKT makes it into the right variable in the script. It all looks perfect in the firebug variable listing. Here are the statements I use to process the JSON response:</div>
<div><br></div><div>function updateSuccess(updateRequest) {</div><div>    updateJson = new OpenLayers.Format.JSON();</div><div>    updateOutput = updateJson.read(updateRequest.responseText);</div><div>    updateStatus = updateOutput.status;</div>
<div>    if (updateStatus == 'added') {</div><div>       new polygone = parcer.read(updateOutput[0]);</div><div>       ...</div><div>       further statements to redraw the layer, etc.</div><div><br></div><div>(updateOutput[0] reflects the fact that I'm providing for potentially multiple polygons being updated -- in the future. For now, I'd be happy if only one worked.</div>
<div><br></div><div>The problem seems to be that the parcer.read statement will not process any variable, just a literal text string. (I've experimented all day substituting different variables and literals.) If I plug in a new MULTIPOLYGON literal, the statement will work, and processing will proceed. Any variable though, and polygone remains undefined. I also experimented with adding quotes to the string inside the variable as I noticed that php didn't include any in the JSON encoding. That made no difference. Am I missing something?? If variables can't be used in a read function, how does one provide for future activity?</div>
<div><br></div><div>I'm using openlayers 2.11, by the way.</div>