#708 - make the WKT format like the other vector formats - serialize/deserialize features instead of geometries

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3158 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-05-21 14:24:55 +00:00
parent 6bbecdbb36
commit 7819bd1743
4 changed files with 165 additions and 124 deletions
+9 -10
View File
@@ -78,7 +78,7 @@
}
function displayWKT(feature) {
var str = wkt.write(feature.geometry);
var str = wkt.write(feature);
// not a good idea in general, just for this demo
str = str.replace(/,/g, ', ');
document.getElementById('info').innerHTML = str;
@@ -86,19 +86,18 @@
function parseWKT() {
var element = document.getElementById('wkt');
var collection = wkt.read(element.value);
var features = wkt.read(element.value);
var bounds;
if(collection) {
if(collection.constructor != Array) {
collection = [collection];
if(features) {
if(features.constructor != Array) {
features = [features];
}
var features = [];
for(var i=0; i<collection.length; ++i) {
features.push(new OpenLayers.Feature.Vector(collection[i]));
for(var i=0; i<features.length; ++i) {
if (!bounds) {
bounds = collection[i].getBounds();
bounds = features[i].geometry.getBounds();
} else {
bounds.extend(features[i].geometry.getBounds());
}
bounds.extend(collection[i].getBounds());
}
vectors.addFeatures(features);