I'm trying to search features using the "esri/search" module. I'm passing the parameters to callback function (Search) to add a feature layer and search features, but i don't see any features added on map in first place. Please check below the function call:
var mysources = mySearch.get("mysources");
mySearch.on("load", function(){
mySearch.Set("mysources",mysources);
mysources.push({
myfeatureLayer: new FeatureLayer("http://arcgis-serveruf-1981283418.us-east-1.elb.amazonaws.com/arcgis/rest/services/MyFiles/LandParcels/FeatureServer/0"),
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
searchFields: ["ADDRESS"],
suggestionTemplate: "Address : ${ADDRESS}",
exactMatch: false,
outFields: ["*"],
name: "land parcels",
labelSymbol: textSymbol,
placeholder: "address of parcels",
maxResults: 6,
maxSuggestions: 6,
enableSuggestions: true,
minCharacters: 1
});
map.addLayer(myfeatureLayer);
});
-
"When using a Map with a SpatialReference other than Web Mercator or Geographic, be sure to set a default GeometryService".Kirk Kuykendall– Kirk Kuykendall2016年01月14日 00:23:08 +00:00Commented Jan 14, 2016 at 0:23
-
I published a new feature service by changing the projection from NAD to Web Mercator. But i couldn't add the layer to map. I even declared the myfeatureLayer as separate variable as suggested by below, but still it remains un-added. Would you suggest were i had gone wrong ?. Thanks-Kirkuser65031– user650312016年01月14日 02:46:47 +00:00Commented Jan 14, 2016 at 2:46
1 Answer 1
You haven't explicitly defined myfeatureLayer
as a variable, so it's not available when you try to run map.addLayer(myfeatureLayer)
.
You could first declare myfeaturelayer
as a variable, then add the variable to mysources
, or you could get the last index of mysources
and add that to the map.
-
I defined the myfeatureLayer as a variable before mysources, but still the layer did not show up on the basemap. Any reasons were i had gone wrong?.user65031– user650312016年01月14日 02:50:06 +00:00Commented Jan 14, 2016 at 2:50
-
Why does myfeatureLayer need to depend on the search function at all? Can you just create a feature layer and add it normally, as in this sample? You're over-complicating things in the above exampleStephen Lead– Stephen Lead2016年01月14日 02:57:12 +00:00Commented Jan 14, 2016 at 2:57
-
Thank you Stephen. I fixed the issue. The features are not highlighted when i click the search with a related value or suggested results.user65031– user650312016年01月15日 04:13:07 +00:00Commented Jan 15, 2016 at 4:13
Explore related questions
See similar questions with these tags.