TypeError: jsonFeatures.map is not a function using fuse-search in leaflet js

المشرف العام

Administrator
طاقم الإدارة
Trying to implement the fuse-search functionality in a leaflet map, however I am getting a TypeError: jsonFeatures.map is not a function. Here is my javascript part of the code:

var map = L.map('map', { zoomControl:false, maxZoom:35 }).fitBounds([[33.0505857631,-97.0891295315],[46.4513087069,-74.8430449085]]); var hash = new L.Hash(map); var additional_attrib = 'created w. qgis2leaf by Geolicious & contributors
'; var feature_group = new L.featureGroup([]); var raster_group = new L.LayerGroup([]); var basemap_0 = L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png", { subdomains: ["otile1", "otile2", "otile3", "otile4"], attribution: 'Tiles courtesy of MapQuest
. Map data (c) OpenStreetMap contributors, CC-BY-SA.' }); basemap_0.addTo(map); var layerOrder=new Array(); function pop_mvpdataset(feature, layer) { var popupContent = 'Company:'+ Autolinker.link(String(feature.properties['Company'])) + 'Business Line:' + Autolinker.link(String(feature.properties['BusinessDescription']))+ 'City:' + Autolinker.link(String(feature.properties['City'])) + 'State:' + Autolinker.link(String(feature.properties['State'])) + 'County:' + Autolinker.link(String(feature.properties['County'])) + 'Phone:' + Autolinker.link(String(feature.properties['Phone'])) + 'Website' + Autolinker.link(String(feature.properties['Website'])) + ''; layer.bindPopup(popupContent); } var exp_mvpdatasetJSON = new L.geoJson(exp_mvpdataset,{ onEachFeature: pop_mvpdataset, pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: feature.properties.icon_exp, iconSize: [50, 45], // size of the icon change this to scale your icon (first coordinate is x, second y from the upper left corner of the icon) iconAnchor: [12, 12], // point of the icon which will correspond to marker's location (first coordinate is x, second y from the upper left corner of the icon) popupAnchor: [0, -14] // point from which the popup should open relative to the iconAnchor (first coordinate is x, second y from the upper left corner of the icon) }) }) }} ); var cluster_groupmvpdatasetJSON= new L.MarkerClusterGroup({showCoverageOnHover: false}); cluster_groupmvpdatasetJSON.addLayer(exp_mvpdatasetJSON); //add comment sign to hide this layer on the map in the initial view. cluster_groupmvpdatasetJSON.addTo(map); feature_group.addTo(map); var title = new L.Control(); title.onAdd = function (map) { this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info" this.update(); return this._div; }; title.update = function () { this._div.innerHTML = 'Search using NAICS or SIC Code' }; title.addTo(map); var osmGeocoder = new L.Control.OSMGeocoder({ collapsed: false, position: 'topleft', text: 'Location Search!', }); osmGeocoder.addTo(map); // Adding FuseSearch Control var searchCtrl = L.control.fuseSearch({collapsed: false}) searchCtrl.indexFeatures(cluster_groupmvpdatasetJSON, ['Company', 'NAICS1', 'PrimarySIC']); feature.layer = cluster_groupmvpdatasetJSON; searchCtrl.addTo(map); // Allow switch between satellite and Hybrid Maps var mapquestOAM = L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg", { maxZoom: 35, subdomains: ["oatile1", "oatile2", "oatile3", "oatile4"], attribution: 'Tiles courtesy of MapQuest. Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency' }); var mapquestHYB = L.layerGroup([L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg", { maxZoom: 35, subdomains: ["oatile1", "oatile2", "oatile3", "oatile4"] }), L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/hyb/{z}/{x}/{y}.png", { maxZoom: 35, subdomains: ["oatile1", "oatile2", "oatile3", "oatile4"], attribution: 'Labels courtesy of MapQuest
. Map data (c) OpenStreetMap contributors, CC-BY-SA. Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency' })]); var baseMaps = { 'Street Map': basemap_0, 'Aerial Imagery': mapquestOAM, 'Imagery with Streets': mapquestHYB }; L.control.layers(baseMaps,{"Manufacturing Companies": cluster_groupmvpdatasetJSON},{collapsed:false}).addTo(map); L.control.scale({options: {position: 'bottomleft',maxWidth: 100,metric: true,imperial: false,updateWhenIdle: false}}).addTo(map);

أكثر...
 
أعلى