<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Find Task not working in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70572#M6257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am a novice at JS, but I have done well with Python scripting in the past. I currently have an application set up in ArcServer but am migrating it over to the JavaScript API for more flexibility. I can't seem to get things to work though. I made use of the "Find" tool example script but things just don't seem to be connecting somewhere. I've had someone else look over the code and they are also stumped. I figured this group here would be a good place to ask for some help. I'm really hoping to get over this hurdle so I can get this online. Everything is looking good, just not working!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've gotten rid of error codes and things still don't seem to work. The Find Task works fine via REST services using the search term I'm using and it shows results. But it doesn't seem to want to do the same in my actual code. I had the Query Task working previously, but wanted to be able to search multiple layers so I switched to the Find Task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will admit I'm not the best script writer yet...again, still pretty new at this. But if I could get some insight on why things don't seem to be working, that would be great. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jul 2012 14:25:24 GMT</pubDate>
    <dc:creator>JessicaKnight1</dc:creator>
    <dc:date>2012-07-13T14:25:24Z</dc:date>
    <item>
      <title>Find Task not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70572#M6257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am a novice at JS, but I have done well with Python scripting in the past. I currently have an application set up in ArcServer but am migrating it over to the JavaScript API for more flexibility. I can't seem to get things to work though. I made use of the "Find" tool example script but things just don't seem to be connecting somewhere. I've had someone else look over the code and they are also stumped. I figured this group here would be a good place to ask for some help. I'm really hoping to get over this hurdle so I can get this online. Everything is looking good, just not working!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've gotten rid of error codes and things still don't seem to work. The Find Task works fine via REST services using the search term I'm using and it shows results. But it doesn't seem to want to do the same in my actual code. I had the Query Task working previously, but wanted to be able to search multiple layers so I switched to the Find Task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will admit I'm not the best script writer yet...again, still pretty new at this. But if I could get some insight on why things don't seem to be working, that would be great. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 14:25:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70572#M6257</guid>
      <dc:creator>JessicaKnight1</dc:creator>
      <dc:date>2012-07-13T14:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70573#M6258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Everything is working as expected, but the map service you're querying is in geographic coordinates (lat, long). The find task is returning data, and it's being added to the map. The issue is that your points are in lat, long while the map is in web mercator. This causes your points to be plotted off the coast of Africa:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]16077[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The quickest fix for this is to use esri.geometry.geographicToWebMercator to convert your geographic coordinates to web mercator. Here's a modified version of your callback function that handles the find task results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function showResults(results){
 var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
 map.graphics.clear();
 dojo.forEach(results, function(result){
&amp;nbsp; &lt;STRONG&gt;result.feature.geometry = esri.geometry.geographicToWebMercator(result.feature.geometry);&lt;/STRONG&gt;
&amp;nbsp; var graphic = result.feature;
&amp;nbsp; graphic.setSymbol(markerSymbol);
&amp;nbsp; map.graphics.add(graphic);
 }); 
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:42:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70573#M6258</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-10T22:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70574#M6259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you so much! I've been fighting with this for weeks and I never would have thought to zoom out. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any way to make that code universal for other tasks I will add in later (a GP task for example) or do I have to use this code each time I show results for my tasks?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 18:47:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70574#M6259</guid>
      <dc:creator>JessicaKnight1</dc:creator>
      <dc:date>2012-07-13T18:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70575#M6260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Any way to make that code universal for other tasks I will add in later (a GP task for example) or do I have to use this code each time I show results for my tasks?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A better way to do this would be to set outSpatialReference on your findParams to match your map's spatial reference. For instance:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
findParams = new esri.tasks.FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
findParams.searchFields = ["FARM_NAME", "LF_NAME", "COMPANY", "FACILITY", "NAME", "Company"];
&lt;STRONG&gt;findParams.outSpatialReference = map.spatialReference;&lt;/STRONG&gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That way you don't need to do anything other than add the results to your map in your callback: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//Display results for Find tool
function showResults(results){
 var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
 map.graphics.clear();
 dojo.forEach(results, function(result){
&amp;nbsp; var graphic = result.feature;
&amp;nbsp; graphic.setSymbol(markerSymbol);
&amp;nbsp; map.graphics.add(graphic);
 }); 
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:42:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-task-not-working/m-p/70575#M6260</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-10T22:42:46Z</dc:date>
    </item>
  </channel>
</rss>

