I'm developing an application in GeoDjango and using Leaflet to show my data.I have loaded my data successfully into the map and added a sidebar where I have my textboxes to input values and a search button. I want to filter data depending on the inserted parameters in the textboxes.
I found an example at http://ipasic.com/article/query-and-filter-leaflet-map-layers/ which uses point data.
Was wondering how to handle polygon data.
Textboxes section
<ul>
<p><strong>LR No:</strong></p>
<input type="text" id="lrno" value="" size="30" />
<br>
<p><strong>Parcel ID:</strong></p>
<input type="text" id="idno" value="" size="30" />
<br>
<p><strong>Parcel No:</strong></p>
<input type="textbox" id="parcel_no" value="" size="30">
<br>
<br>
<button id="searchbutton" role="button" class="btn btn-primary">Search</button>
<button id="resetbutton" role="button" class="btn btn-primary">Reset</button>
</ul>
<div id="results">
<h2>Results</h2>
</div>
Map.js
var parcel = L.geoJson();
var dataurl = '/data/';
$.getJSON(dataurl, function (data) {
parcel.addData(data).setStyle(featureStyle);
parcel.eachLayer(function (layer) {
layer.on('click',function(e){
var layer = e.target;
this.setStyle({
weight: 4,
opacity: 1,
color: 'orange',
dashArray: '3'
});
if (!L.Browser.ie && !L.Browser.opera) {
this.bringToFront();
}
info.update(layer.feature.properties);
map.fitBounds(e.target.getBounds());
});
layer.on('mouseout',function(e){
parcel.setStyle(featureStyle);
});
});});
I can't really figure out what function I should use for this..
Any help ?
Best Answer
UPDATE I found a way of handling the search using FuseSearch! .I have used it in my code and it works well.Only that when I click on the output list,it doesn't show the corresponding polygon in the map.
Code
Here is a code for the layer click for the popup
This I know will help a lot in this endeavour..Help