<?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 Re: Highlight features layer if selected search result intersect with feature layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013009#M71247</link>
    <description>&lt;P&gt;Thank you John, I was thinking the same. I can't simulate this on codepen as all API are secured. I am new to ESRI GIS. Could you please guide me how to wait for the view to finish updating?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Dec 2020 19:07:18 GMT</pubDate>
    <dc:creator>anuragmittal</dc:creator>
    <dc:date>2020-12-30T19:07:18Z</dc:date>
    <item>
      <title>Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012594#M71219</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added different features layer on map and have a working code to highlight the feature layer once user click on the map (I am using hitTest on mouse click event). But I am trying to do the same (highlight feature layer) once user searched an address and that address falls on one of feature layer. I am not able to make it work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code snippet&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;			search.on("search-complete", function(event)
			{			
			    //take lat and long from Esri search if geometry type is point or polygon
			    let lat, longt;
			    if(event.results[0].results[0].feature.geometry.type == 'point') {
			        lat = event.results[0].results[0].feature.geometry.latitude;
			        longt = event.results[0].results[0].feature.geometry.longitude;
			    } else if(event.results[0].results[0].feature.geometry.type == 'polygon') {
			        lat = event.results[0].results[0].feature.geometry.centroid.latitude;
			        longt = event.results[0].results[0].feature.geometry.centroid.longitude;
			    }		
			   let pointVar = new Point({
			        latitude:lat,
			        longitude:longt
			    });

				view.hitTest(pointVar).then(function(response)
				{//alert("test");
					console.log(response);
					if (response &amp;amp;&amp;amp; response.results.length &amp;gt; 0 &amp;amp;&amp;amp; response.results[0].graphic &amp;amp;&amp;amp; response.results[0].graphic != undefined &amp;amp;&amp;amp; response.results[0].graphic.attributes != undefined ) {
						let graphic = response.results[0].graphic;
									
						view.whenLayerView(graphic.layer).then(function(lyrView){
								if (highlightSelect) {
							highlightSelect.remove();
						}
							highlightSelect = lyrView.highlight(graphic);
						});	
					}
				
				});
			}); &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 16:35:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012594#M71219</guid>
      <dc:creator>anuragmittal</dc:creator>
      <dc:date>2020-12-29T16:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012717#M71222</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;Even I tried emitting click event on search-complete event of search widget. But that also not working. Here is my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;search.on('search-complete', function(event){
				let lat, longt;
			    if(event.results[0].results[0].feature.geometry.type == 'point') {
			        lat = event.results[0].results[0].feature.geometry.latitude;
			        longt = event.results[0].results[0].feature.geometry.longitude;
			    } else if(event.results[0].results[0].feature.geometry.type == 'polygon') {
			        lat = event.results[0].results[0].feature.geometry.centroid.latitude;
			        longt = event.results[0].results[0].feature.geometry.centroid.longitude;
			    }		
			   let pointVar = new Point({
			        latitude:lat,
			        longitude:longt
			    });
				var scrPt = view.toScreen(pointVar);
				view.emit('click', {bubbles: true, cancelable: true,mapPoint: pointVar,screenPoint: scrPt});
			});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 19:00:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012717#M71222</guid>
      <dc:creator>anuragmittal</dc:creator>
      <dc:date>2020-12-29T19:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012777#M71229</link>
      <description>&lt;P&gt;In your first example you pass in a Point instead of ScreenPoint to hitTest(...), and in the second example you're not calling hitTest(...), so it's hard to tell what is going on.&amp;nbsp; Do you have a very simple codepen/jsbin/other showing the issue?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 22:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012777#M71229</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2020-12-29T22:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012950#M71243</link>
      <description>&lt;P&gt;Thank you John for the reply. After&amp;nbsp;using&amp;nbsp;&lt;SPAN&gt;ScreenPoint&amp;nbsp;to hiTest() it works only if searched location is visible on screen window. I have set zoom level to 15, so if I&amp;nbsp;searched an address that's not visible on viewable screen then it doesn't&amp;nbsp;work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is my updated code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;			var search = new Search({
				view: view,
				//container:"searchDiv",
				popupEnabled: false, 
				resultGraphicEnabled: false,
				enableHighlight: false,
				//allPlaceholder:'#rn:msg:CUSTOM_MSG_MAP_SEARCH_PLACEHOLDER#',
				sources: [customSearchSource, cityOwnedParcelSearch, waterTreatmentPlanSearch, waterProductionWellSearch, sampleStationSearch],
				includeDefaultSources: false,
				maxResults: 8,
				maxSuggestions: 8,
			});
			
			search.on("search-complete", function(event)
			{			
			    //take lat and long from Esri search if geometry type is point or polygon
			    let lat, longt;
			    if(event.results[0].results[0].feature.geometry.type == 'point') {
			        lat = event.results[0].results[0].feature.geometry.latitude;
			        longt = event.results[0].results[0].feature.geometry.longitude;
			    } else if(event.results[0].results[0].feature.geometry.type == 'polygon') {
			        lat = event.results[0].results[0].feature.geometry.centroid.latitude;
			        longt = event.results[0].results[0].feature.geometry.centroid.longitude;
			    }		
			   let pointVar = new Point({
			        latitude:lat,
			        longitude:longt
			    });

				//selectedGraphic.geometry = webMercatorUtils.geographicToWebMercator(pointVar);
				view.hitTest(view.toScreen(pointVar)).then(function(response)
				{		
					if (response &amp;amp;&amp;amp; response.results.length &amp;gt; 0 &amp;amp;&amp;amp; response.results[0].graphic &amp;amp;&amp;amp; response.results[0].graphic != undefined &amp;amp;&amp;amp; response.results[0].graphic.attributes != undefined ) {
						let graphic = response.results[0].graphic;

						if (highlightSelect) {
							highlightSelect.remove();
						}
						view.whenLayerView(graphic.layer).then(function(lyrView){
							highlightSelect = lyrView.highlight(graphic);
						});	
					}
				});		 
				search.clear();

			}); &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 16:52:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012950#M71243</guid>
      <dc:creator>anuragmittal</dc:creator>
      <dc:date>2020-12-30T16:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012967#M71245</link>
      <description>&lt;P&gt;Correct, hitTest(..) only works with information in the current view since it's designed to work when the user interacts with the view.&amp;nbsp; Hard to tell without a codepen/jsbin of the exact interactions going on, but here are a few possible alternatives for you to explore:&lt;/P&gt;&lt;P&gt;- make sure Search is configured to place the user over the found result, wait for the view to finish updating, then call hitTest(...).&lt;/P&gt;&lt;P&gt;- use goTo(...) to place the view over the found result, wait for the view to finish updating, then call hitTest(...).&lt;/P&gt;&lt;P&gt;- use goTo(...) to place the view over the found result, wait for the view to finish updating, then use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#fetchFeatures" target="_self"&gt;fetchFeatures&lt;/A&gt; to get all features and not just the first one.&lt;/P&gt;&lt;P&gt;- ask all the individual layer(s) if they have any data at the searched location by calling queryFeatures(...).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 17:33:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1012967#M71245</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2020-12-30T17:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013009#M71247</link>
      <description>&lt;P&gt;Thank you John, I was thinking the same. I can't simulate this on codepen as all API are secured. I am new to ESRI GIS. Could you please guide me how to wait for the view to finish updating?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 19:07:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013009#M71247</guid>
      <dc:creator>anuragmittal</dc:creator>
      <dc:date>2020-12-30T19:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013012#M71248</link>
      <description>&lt;P&gt;You can watch for the MapView property called&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#updating" target="_self"&gt;updating&lt;/A&gt;&amp;nbsp;to be false.&amp;nbsp; You can directly watch this property, or for this use-case maybe use&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html" target="_self"&gt;watchUtils&lt;/A&gt;&amp;nbsp;which might be more appropriate.&amp;nbsp; The assumption is that after navigating to a search result the view will be updating, and you want to wait before interrogating via hitTest(...) or other.&amp;nbsp; You could skip this part and see if it works for your use-case, and then add it in if it doesn't quite work as you need.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// ALL updating PROPERTY CHANGES //
mapView.watch('updating', (updating) =&amp;gt;{
  console.log('Updating: ', updating);
});

// WHEN updating IS FALSE ONE TIME //
watchUtils.whenFalseOnce(mapView, 'updating', ()=&amp;gt; {
  console.log('View Not Updating');
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 19:59:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013012#M71248</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2020-12-30T19:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight features layer if selected search result intersect with feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013023#M71252</link>
      <description>&lt;P&gt;Perfect.&amp;nbsp;watchUtils worked for me. Thank you a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 19:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/highlight-features-layer-if-selected-search-result/m-p/1013023#M71252</guid>
      <dc:creator>anuragmittal</dc:creator>
      <dc:date>2020-12-30T19:56:08Z</dc:date>
    </item>
  </channel>
</rss>

