Bringing in a service twice

750
2
Jump to solution
08-16-2013 02:47 PM
KennethRichards
New Contributor III
Is there a way to bring a service in twice? I am bringing in my service once as a featurelayer. This is where I do most of the work with my map but I also want to run a FindTask on the same service.

findTask = new esri.tasks.FindTask(wellFeatureLayer);  findTask = new esri.tasks.FindTask("http://services.azgs.az.gov/ArcGIS/rest/services/....");  wellFeatureLayer = new esri.layers.FeatureLayer("http://services.azgs.az.gov/ArcGIS/rest/services/...",{         mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //data on demand         infoTemplate: infoTemplate,         outFields: ["*"]       });


I have tried bringing in the service both ways at the same time and that gives me a domain error. I also tried passing the the wellFeatureLayer  variable to the find task. That just gives me an undefined path error.
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
The find task expects the url to the map server instead of to a feature layer. For example if I wanted to use the Find Task I'd supply this url:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer


And if I wanted to add a feature layer from that map service I'd do something like this where I'd add the index of the layer.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer/0

View solution in original post

0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor
The find task expects the url to the map server instead of to a feature layer. For example if I wanted to use the Find Task I'd supply this url:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer


And if I wanted to add a feature layer from that map service I'd do something like this where I'd add the index of the layer.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer/0
0 Kudos
KennethRichards
New Contributor III
The find task expects the url to the map server instead of to a feature layer. For example if I wanted to use the Find Task I'd supply this url:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer


And if I wanted to add a feature layer from that map service I'd do something like this where I'd add the index of the layer.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer/0


I guess I should read over the API Reference a little more carefully next time. 🙂
Thanks for the help. That seems to have solved the problem.
0 Kudos