<?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 Click Feature to Open URL in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/click-feature-to-open-url/m-p/1011361#M71150</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm trying to get a URL to open up from a link in an attribute field when&amp;nbsp; the feature is clicked on. I have added the following sample code taken from another post to MapManager.js and have gotten it to work with the sample links that came with it.&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;var&lt;/SPAN&gt;&amp;nbsp;featureLayer&amp;nbsp;=&amp;nbsp;&lt;SPAN class=""&gt;new&lt;/SPAN&gt;&amp;nbsp;FeatureLayer(&lt;SPAN class=""&gt;"&lt;A href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fsampleserver1.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FDemographics%2FESRI_Census_USA%2FMapServer%2F3" target="_blank" rel="noopener"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3&lt;/A&gt;"&lt;/SPAN&gt;);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;map.addLayer(featureLayer);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;//Code&amp;nbsp;for&amp;nbsp;the&amp;nbsp;specific&amp;nbsp;URL&amp;nbsp;to&amp;nbsp;open&amp;nbsp;in&amp;nbsp;a&amp;nbsp;new&amp;nbsp;window&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;featureLayer.on(&lt;SPAN class=""&gt;'click'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;function&lt;/SPAN&gt;(e){&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;var&lt;/SPAN&gt;&amp;nbsp;specific&amp;nbsp;=&amp;nbsp;e.graphic.attributes[&lt;SPAN class=""&gt;'SpecificAttribute'&lt;/SPAN&gt;]&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;window.open(&lt;SPAN class=""&gt;"&lt;A href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2FYourUrl.com%2F" target="_blank" rel="noopener"&gt;http://YourUrl.com/&lt;/A&gt;"&lt;/SPAN&gt;+specific);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;});&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I don't want to create a new feature layer, I would like to use an existing layer - how do I alter the code to do this? Also, will this work on a point feature as well as a polygon? Because right now it doesn't work on point features.&lt;/P&gt;&lt;P&gt;I'm inexperienced with ArcGIS API for JavaScript but I'm trying to use online resources to find a solution so any help would be appreciated as I've spent a long time trying to get this to work!&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2020 03:51:03 GMT</pubDate>
    <dc:creator>Keagan1</dc:creator>
    <dc:date>2020-12-21T03:51:03Z</dc:date>
    <item>
      <title>Click Feature to Open URL</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/click-feature-to-open-url/m-p/1011361#M71150</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm trying to get a URL to open up from a link in an attribute field when&amp;nbsp; the feature is clicked on. I have added the following sample code taken from another post to MapManager.js and have gotten it to work with the sample links that came with it.&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;var&lt;/SPAN&gt;&amp;nbsp;featureLayer&amp;nbsp;=&amp;nbsp;&lt;SPAN class=""&gt;new&lt;/SPAN&gt;&amp;nbsp;FeatureLayer(&lt;SPAN class=""&gt;"&lt;A href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fsampleserver1.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FDemographics%2FESRI_Census_USA%2FMapServer%2F3" target="_blank" rel="noopener"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3&lt;/A&gt;"&lt;/SPAN&gt;);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;map.addLayer(featureLayer);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;//Code&amp;nbsp;for&amp;nbsp;the&amp;nbsp;specific&amp;nbsp;URL&amp;nbsp;to&amp;nbsp;open&amp;nbsp;in&amp;nbsp;a&amp;nbsp;new&amp;nbsp;window&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;featureLayer.on(&lt;SPAN class=""&gt;'click'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;function&lt;/SPAN&gt;(e){&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;var&lt;/SPAN&gt;&amp;nbsp;specific&amp;nbsp;=&amp;nbsp;e.graphic.attributes[&lt;SPAN class=""&gt;'SpecificAttribute'&lt;/SPAN&gt;]&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;window.open(&lt;SPAN class=""&gt;"&lt;A href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2FYourUrl.com%2F" target="_blank" rel="noopener"&gt;http://YourUrl.com/&lt;/A&gt;"&lt;/SPAN&gt;+specific);&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;});&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I don't want to create a new feature layer, I would like to use an existing layer - how do I alter the code to do this? Also, will this work on a point feature as well as a polygon? Because right now it doesn't work on point features.&lt;/P&gt;&lt;P&gt;I'm inexperienced with ArcGIS API for JavaScript but I'm trying to use online resources to find a solution so any help would be appreciated as I've spent a long time trying to get this to work!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 03:51:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/click-feature-to-open-url/m-p/1011361#M71150</guid>
      <dc:creator>Keagan1</dc:creator>
      <dc:date>2020-12-21T03:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Click Feature to Open URL</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/click-feature-to-open-url/m-p/1019461#M71471</link>
      <description>&lt;P&gt;Try to get your existing feature layer with the following logic (let is just another forma of declaring a variable which I personally prefer, you can as well use var). And don't get confused of (e) =&amp;gt; { //code } it means the same as function (e) { //code }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let myFeatureLayerTitle = 'TitleOfYourExistingFeatureLayer';
let myFeatureLayer = webmap.allLayers.find((layer) =&amp;gt; {
   return layer.title === myFeatureLayerTitle;
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't know the title of your layer you can also use the ID property or something else which identifies the layer. Additionally you can put the var view variable into the global scope (put it before the API require statement require([ ... ] ..... ) so you can use it in your browser dev tools and access your layers with view.map.allLayers.items&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2021 13:47:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/click-feature-to-open-url/m-p/1019461#M71471</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2021-01-24T13:47:45Z</dc:date>
    </item>
  </channel>
</rss>

