0

I am trying to add my CSVLayer as a source for the Search widget, however, I've been unsuccessful. My Search widget searches addresses and I was able to add one of the sources from this example (https://developers.arcgis.com/javascript/jssamples/search_multiplesources.html) successfully, however my CSVLayer doesn't return any results in the Search widget.

Has anyone had any success or experience with adding a CSVLayer as a source for the Search widget in ArcGIS Javascript? Below is a code snippet...

var csv = new CSVLayer("file.csv", {
      outFields: ["*"]
    });
var search = new Search({
      enableButtonMode: false,
      enableLabel: false,
      enableInfoWindow: true,
      showInfoWindowOnSelect: false,
      map: map
    }, "search");

    var sources = search.get("sources");

    sources.push({
      featureLayer: csv,
      searchFields: ["Name"],
      displayField: "Name",
      exactMatch: false,
      outFields: ["*"],
      name: "Foo",
      placeholder: "FooPlace",
      maxResults: 6,
      maxSuggestions: 6,

      infoTemplate: template,
      enableSuggestions: true,
      minCharacters: 0
    });

Could the issue be that my csv var is technically a CSVLayer and not a FeatureLayer?

  • 1
    Are you receiving an error or just not receiving expected results? – MaryBeth Mar 31 '16 at 15:12
  • 1
    No error and my Foo layer even shows in the Search drop-down but when i search on Foo Place I get no results so it seems that the Search widget isn't actually reading the CSVLayer. My CSVLayer displays in my map with no issue, and my InfoTemplate works as well. – joshua Mar 31 '16 at 15:16
  • 1
    If you are not joining the CSV to anything spatial, a spatial tool is not going to find it. – MaryBeth Mar 31 '16 at 16:03
  • 1
    I'm mapping the var csv, points on a map based on the latitude and longitude columns in the file.csv. – joshua Mar 31 '16 at 17:07
  • 1
    can you post your csv file please, or at least and excerpt. do the standard check for field names being nothing out of ordinary, and try to avoid null values and that there's no syntax errors (commas missing or similar) – belzebu Mar 31 '16 at 23:40
0

From the API reference:

The Search widget provides a way to perform search capabilities based on locator service(s) and/or map/feature service feature layer(s)

https://developers.arcgis.com/javascript/jsapi/search-amd.html

As you speculated in your own question, a CSVlayer is not one of the widget's supported inputs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.