Note that there are some explanatory texts on larger screens.

plurals
  1. PO.read .write .replace string elements in jQuery
    primarykey
    data
    text
    <p>I have these 2 functions (serialize and deserialize) in Javascript (below) and I want to change it to jQuery. I am wondering what would the right replacement for read and write in jQuery. Read and write strings are from and to a Textarea. This is part of Openlayers vector formats, getting geometries into / from OL map canvas.</p> <p>Serialize is outputing the geometries from mapcanvas to textarea.</p> <pre><code>function serialize(feature) { var type = document.getElementById("formatType").value; var pretty = document.getElementById("prettyPrint").checked; var str = formats['out'][type].write(feature, pretty); str = str.replace(/,/g, ', '); document.getElementById('output').value = str; } </code></pre> <p>Deserialize is reading string from Textarea into OL mapcanvas.</p> <pre><code>function deserialize() { var element = document.getElementById('text'); var type = document.getElementById("formatType").value; var features = formats['in'][type].read(element.value); var bounds; if(features) { if(features.constructor != Array) { features = [features]; } for(var i=0; i&lt;features.length; ++i) { if (!bounds) { bounds = features[i].geometry.getBounds(); } else { bounds.extend(features[i].geometry.getBounds()); } } vectors.addFeatures(features); map.zoomToExtent(bounds); var plural = (features.length &gt; 1) ? 's' : ''; element.value = features.length + ' feature' + plural + ' added'; } else { element.value = 'Bad input ' + type; } } </code></pre> <p>Thanks in advance.</p> <p>Again, I am asking about the read and write function equivalent in jQuery. These 2 lines:</p> <pre><code>var str = formats['out'][type].write(feature, pretty); var features = formats['in'][type].read(element.value); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload