[OpenLayers-Users] Identify feature by attribute
Greg Allensworth
gregor at greeninfo.org
Tue Jan 8 14:19:58 PST 2013
On 1/8/2013 2:16 PM, Jerome A. Wendell wrote:
> Greg,
> Thank you very much for your reply. Is there a way to
> input the feature identifier, or would that have to
> be coded in a script?
You would need to write your own logic to figure out which Feature is
the one you want. Fortunately, the Vector Layer's .feature" attribute
can be iterated easily, and Features have their .attributes attribute.
So you can loop like this:
var feature = null;
for (var i=0, l=VECTORS.features.length; i++) {
var f = VECTORS.features[i]
if (f.attributes.state_name == 'Maryland') { feature = f; break; }
}
if (feature) CLICKER.select(feature);
else alert ("Not found!");
--
Greg Allensworth, Web GIS Developer
BS A+ Network+ Security+ Linux+ Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510 San Francisco CA 94104
PH: 415-979-0343 x302 FX: 415-979-0371 email: gregor at greeninfo.org
Web: www.GreenInfo.org www.MapsPortal.org
Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org
More information about the Users
mailing list