[OpenLayers-Users] What is the easiest way to search a vectorlayer(s)?
Arnd Wippermann
arnd.wippermann at web.de
Thu Feb 28 13:03:56 PST 2013
Hi,
var mh_layer = new OpenLayers.Layer.Vector("Manhole", ...
the layer name is "Manhole" and mh_layer is the variable that holds the
layer object.
So use
<input type="hidden" name="layer" value="Manhole">
Regards,
Arnd
-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von boesiii
Gesendet: Donnerstag, 28. Februar 2013 20:43
An: openlayers-users at lists.osgeo.org
Betreff: Re: [OpenLayers-Users] What is the easiest way to search a
vectorlayer(s)?
I am having a problem with getting the layer name. When I run the code I
get an error "Cannot read property 'features' of undefined", obviously
because it is not getting the layer name.
.....html......
<form name="myform" action="" method="GET">
<input type="hidden" name="layer" value="mh_layer">
<input TYPE="button" NAME="button" Value="Search"
onClick="searchTest(this.form)">
</form>
....html.....
function searchTest () {
layer = map.getLayersByName(form.layer.value)[0];
searchVector(layer,keyword);
}
var map, select;
function init(){
map = new OpenLayers.Map('map', {
units: 'm',
numZoomLevels: 19,
projection: epsg900913,
displayProjection: epsg4326 //Is used for displaying
coordinates in appropriate CRS by MousePosition control
});
var mh_layer = new OpenLayers.Layer.Vector("Manhole", {
searchfields: [ 'STRUCT_ID', 'OWNER_NAME', 'GPS_DATE' ],
titlefield: 'STRUCT_ID',
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "./mh.geojson",
format: new OpenLayers.Format.GeoJSON({
extractStyles: true,
extractAttributes: true
})
})
});
--
View this message in context:
http://osgeo-org.1560.n6.nabble.com/What-is-the-easiest-way-to-search-a-vect
or-layer-s-tp5036948p5037574.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
More information about the Users
mailing list