Zoom to features after done loading them.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@2992 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-04-03 16:42:19 +00:00
parent d0115ccf26
commit 140090ec20

View File

@@ -87,6 +87,7 @@
function parseWKT() {
var element = document.getElementById('wkt');
var collection = wkt.read(element.value);
var bounds;
if(collection) {
if(collection.constructor != Array) {
collection = [collection];
@@ -94,8 +95,14 @@
var features = [];
for(var i=0; i<collection.length; ++i) {
features.push(new OpenLayers.Feature.Vector(collection[i]));
if (!bounds) {
bounds = collection[i].getBounds();
}
bounds.extend(collection[i].getBounds());
}
vectors.addFeatures(features);
map.zoomToExtent(bounds);
var plural = (features.length > 1) ? 's' : '';
element.value = 'Feature' + plural + ' added'
} else {