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