Searching Feature Layer By its Attribute
Here's the screenshot 'coz I'm not good at explaining.
A pop up will show if the feature layer is found, it is also selected.
Here's the link for displaying Popups.
Here's the code below for reference:
Supposed your Vector Layer name is "layer_agao" and your SelectFeature Control is "selectControl".
This should be placed inside your "init()" function in which it is called as the body loads.
And for the HTML markup:
You just need to change the IDs depending on your JQuery code.
That's all! :D
A pop up will show if the feature layer is found, it is also selected.
Here's the link for displaying Popups.
Here's the code below for reference:
Supposed your Vector Layer name is "layer_agao" and your SelectFeature Control is "selectControl".
$("#forminput").change(function(){
for (var f = 0; f < layer_agao.features.length; f++) {
if (layer_agao.features[f].attributes.newpin == this.value) {
featsel = layer_agao.features[f];
$("#mybutton").click(function(){
selectControl.clickFeature(featsel);
});
break;
}
}
});
This should be placed inside your "init()" function in which it is called as the body loads.
And for the HTML markup:
{% csrf_token %}
<select name="q" class="form-control" id="forminput">
<option type="text" value=""><b>Select Land PIN</b></option>
{% for getlandpins in query_map %}
<option type="text" value="{{ getlandpins.newpin }}">{{ getlandpins.newpin }}
</option>
{% endfor %}
</select>
<input type="button" class="btn btn-primary" value="Show Info" id="mybutton">
</form>
You just need to change the IDs depending on your JQuery code.
That's all! :D
