I am new to the 4.xyz API and am trying to figure out how to access an attribute of a feature that's being consumed by my popup. I'd been using the 3.xyz API for many years.
In the 3.xyz API I did this all the time using IdentifyTask and IdentifyParameters with dojo.dom and dojo.on in my popups, with no problem.
However, with the 4.xyz API, since the popup is now part of the MapView and you don't need all the Identify-things and dom and on to create a popup, I'm trying to figure out how to grab the value of one of the items in my popupTemplate.
I have a feature layer as thus:
<SPAN class="keyword token">var</SPAN> parcelsLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"https://jcgis.jacksongov.org/arcgis/rest/services/Cadastral/TaxParcelsTest/MapServer/0"</SPAN><SPAN class="punctuation token">,</SPAN>
outFields<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Parcel_ID"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"SitusAddress"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"SitusCity"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"owner"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
popupTemplate<SPAN class="punctuation token">:</SPAN> thepopup
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>And before that I have my popup template:
<SPAN class="keyword token">var</SPAN> thepopup <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"{SitusAddress}"</SPAN><SPAN class="punctuation token">,</SPAN>
content<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"<b>Parcel Num:</b> {Parcel_ID}<br><b>Address:</b> {SitusAddress}<br><b>City:</b> {SitusCity}<br><b>Owner:</b> {owner}"</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>So that when I click on a parcel, those 4 items are loaded into the popup. What I want to do is grab the "{Parcel_ID}" and assign its value to a variable, like:
var parcelnum = grab the {Parcel_ID} somehow
I know that Popup has a selectedFeature property, which is a Graphic which has attributes, but it's not clear to me how to grab a particular attribute. As in something like:
var parcelnum = view.popup.selectedFeature.attributes[1];
But of course that doesn't work that way.
Am I going about this the right way? Or if I want to do what I want to do, do I need to do it the same way I did using the 3.xyz API?
Thanks.