[OpenLayers-Users] Select geojson feature from hyperlink

Eric Lemoine eric.lemoine at camptocamp.com
Wed Jan 13 23:49:59 EST 2010


On Thursday, January 14, 2010, Jtrsmith <jtrsmith at gmail.com> wrote:
>
> I have a map that is displaying a set of polygons from geojson, when selected
> these polygons display a popup which contains attributes from the geojson.
>
> Is it possible to have a link on the page (not on the map) that will trigger
> the selectfeature event?
> I would like to have a list of the features to the right of my map and when
> selected the map will find the feature, select it, and open the popup. Is
> this possible?

yes, the ids of the list elements would match the fids of the
features. So when an element is clicked you can look up the
corresponding feature and select it.

> Also wondering if it is possible to select a feature by using a search field
> to search a custom attribute from geojson?

OpenLayers reads a GeoJSON FeatureCollection document into an array of
feature (OpenLayers.Feature.Vector) objects, with each feature object
having an "attributes" property containing the properties of the
feature. So once you have this array of features you can do searches.
If you have features in a vector layer the array of features is
accessible at layer.features.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list