[OpenLayers-Users] Zoom to a particular feature

Ralph Dell RDell at CatawbaCountyNC.gov
Wed Jun 1 11:51:39 EDT 2011


Hopefully I am not misunderstanding your question.

Set up a filter, add it to your vector layer, and then zoom to the feature if that is your objective

filter = new OpenLayers.Filter.Comparison({
		type: OpenLayers.Filter.Comparison.EQUAL_TO,
		property: "foo",
		value: '123'
	});

selLayer = new OpenLayers.Layer.Vector("Selected", {
	strategies: [new OpenLayers.Strategy.Fixed()],
	styleMap: styleMap,
	filter: filter,
    protocol: protocol
  });

map.zoomToExtent(selLayer.getDataExtent());


Ralph Dell

-----Original Message-----
From: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Luís de Sousa
Sent: Wednesday, June 01, 2011 10:45 AM
To: users at openlayers.org
Subject: [OpenLayers-Users] Zoom to a particular feature

Hello everyone,

I have this webpage where I must zoom to a particular feature that
matches a string given by the user. A similar issue has been
previously raised in this thread:

http://lists.osgeo.org/pipermail/openlayers-users/2011-March/019820.html

Where a GetFeature request is suggested to obtain the bounding boxes
of the layer's features. The problem is that I have layers with about
a thousand features, which quickly clog the webpage with a slow
connection.

My question is: can I obtain the bounding box for a particular feature
that matches a particular condition such as ATTRIBUTE=KEY with a
GetFeature request? Or using a different method?

Thank you,

Luís
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


More information about the Users mailing list