Skip to content

fuse search failed to display search results popup #270

@tabreha86

Description

@tabreha86

fuse search could not display search results popup after clicking on the index keys from geojson file.
here goes my code..

sample geojson data

var exp_Parcel = {
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },

"features": [
{ "type": "Feature", "properties": { "color_qgis2leaf": '#e05acf', "border_color_qgis2leaf": '#000000', "radius_qgis2leaf": 1.3, "transp_qgis2leaf": 1.0, "transp_fill_qgis2leaf": 1.0, "pid": 37, "PIC": "F01", "Block_Code": "T01", "Purpose": "መንበሪ", "Lease_Period": 50, "Payment_Completion": 30, "Land_Type": "ዝተካረየ ቦታ", "Area": 500.000000, "Height": "g+3", "Expense": 1500.000000, "Initial_price": 1650.000000, "Grade": "1ይ - 2ይ", "Bid_Round": 0, "Complain": "No", "City": "መቐለ", "Sub_City": "ሓወልቲ", "Wereda": "", "kebele": "", "Location": "ሓወልቲ", "L_Description": "", "East": "????", "West": "f03", "North": "F01", "South": "f04", "Water": "Yes", "E_Power": "Yes", "Road": "Yes", "Telephone": "Yes", "Status": "Available", "_Flag": 0, "Reg_Date": "2007/09/20", "Given_Date": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 39.473685174223803, 13.527316687427279 ], [ 39.473677696856114, 13.527166422577492 ], [ 39.473914538972764, 13.527161760750269 ], [ 39.473924898816776, 13.527316233730463 ], [ 39.473685174223803, 13.527316687427279 ], [ 39.473685174223803, 13.527316687427279 ] ] ] } },
{ "type": "Feature", "properties": { "color_qgis2leaf": '#e05acf', "border_color_qgis2leaf": '#000000', "radius_qgis2leaf": 1.3, "transp_qgis2leaf": 1.0, "transp_fill_qgis2leaf": 1.0, "pid": 38, "PIC": "F02", "Block_Code": "T01", "Purpose": "መንበሪ", "Lease_Period": 50, "Payment_Completion": 25, "Land_Type": "ባዶ ቦታ", "Area": 345.000000, "Height": "g+1", "Expense": 320.000000, "Initial_price": 780.000000, "Grade": "1ይ - 3ይ", "Bid_Round": 0, "Complain": "No", "City": "መቐለ", "Sub_City": "ዓይደር", "Wereda": "", "kebele": "", "Location": "ዓይደር", "L_Description": "", "East": "F01", "West": "F01", "North": "መንገዲ", "South": "F03", "Water": "Yes", "E_Power": "Yes", "Road": "Yes", "Telephone": "Yes", "Status": "Available", "_Flag": 0, "Reg_Date": "2007/09/20", "Given_Date": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 39.473677696856114, 13.527166422577492 ], [ 39.473914538972764, 13.527161760750269 ], [ 39.473904905011707, 13.527005170551833 ], [ 39.473672358321409, 13.527004209120372 ], [ 39.473677696856114, 13.527166422577492 ], [ 39.473677696856114, 13.527166422577492 ] ] ] } },
.........

javascript code to load data

var exp_ParcelJSON = new L.geoJson(exp_Parcel,{
onEachFeature: function (feature, layer) {
//add label on load
var popupContent = 'some text contents goes here';
layer.bindPopup(popupContent);
var bounds = layer.getBounds();
// Get center of bounds
var center = bounds.getCenter();
// Use center to put marker on map
var marker = L.circleMarker(center).addTo(map); // Make appear above other map features
marker.bindLabel(feature.properties['PIC'],{noHide:true}).addTo(map);
},
style: function (feature) {
return {color: feature.properties.border_color_qgis2leaf,
fillColor: feature.properties.color_qgis2leaf,
weight: feature.properties.radius_qgis2leaf,
opacity: feature.properties.transp_qgis2leaf,
fillOpacity: feature.properties.transp_qgis2leaf};
}
});

javascript code to add the fuse search control

var searchCtrl = L.control.fuseSearch();
searchCtrl.addTo(map);
//load parcel data
searchCtrl.indexFeatures(exp_Parcel.features, ['PIC', 'Purpose', 'Area']);

map_screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions