[OpenLayers-Users] Rendering 2 or more Vector Features (WKT) in
OpenLayer Canvas e.g. OpenLayers Vector Format Example
Noli Sicad
nsicad at gmail.com
Tue Jul 5 01:00:25 EDT 2011
Hi,
In this OpenLayers Vector format example,
http://openlayers.org/dev/examples/vector-formats.html
I am trying to render 2 or more Vector Features, in the case 3 POINTS
as a result of Spatialite Query.
~~~~~~
POINT(145.052097 -37.834855) POINT(138.599703 -34.967724)
POINT(145.021417 -37.88986)
~~~~~~
I copy and paste this text into the textarea and then I click add
feature button. It is only 1 Feature is added.
1 feature added
Now, the question, What would be the right separation for these 3
POINT WKT Features?
As you can see this function deserialize(below), it is capable of
adding 1 or more vector WKT features.
var plural = (features.length > 1) ? 's' : '';
~~~~~~~~~~~
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<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 > 1) ? 's' : '';
element.value = features.length + ' feature' + plural
+ ' added';
} else {
element.value = 'Bad input ' + type;
}
}
~~~~~~~~~~~~~~~~~~~~
How can I modify this function deserialize() inorder to render 2 or
more points, lines, or polygons (i.e. WKT features)?
And what would the right separation of the data?
Thanks in advance.
Noli
More information about the Users
mailing list