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?

asked Mar 31, 2016 at 14:51
6
  • 1
    Are you receiving an error or just not receiving expected results? Commented Mar 31, 2016 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. Commented Mar 31, 2016 at 15:16
  • 1
    If you are not joining the CSV to anything spatial, a spatial tool is not going to find it. Commented Mar 31, 2016 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. Commented Mar 31, 2016 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) Commented Mar 31, 2016 at 23:40

1 Answer 1

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.

answered Apr 4, 2016 at 17:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.