I was inspired by KGerrow's blog post to autogeneraet some attributes when creating a feature since it could save hundreds of hours of time. I'm looking for some feedback on my methods and code below. My aim is to autopopulate the field of one point feature layer from a field value of another point feature layer when I generate a new feature in a web map. What makes this different than what I have seen is that I have to buffer the point first to make sure the data is joined correctly.
I I think I'm missing some key piece of code to put the data from layer A into layer B. When I test
- Define var A and field I want to extract from
- Define var B and field I want to put the value into
- Define var C - which buffers the A 20 feet so when the new feature is created next to it, it pulls the info from A into B.
- Return Layer A field ID into newly generated feature of Layer B into ID field.
<SPAN class="keyword token">var</SPAN> A <SPAN class="operator token">=</SPAN> <SPAN class="token function">FeatureSetByName</SPAN><SPAN class="punctuation token">(</SPAN>$map<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"A"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">var</SPAN> B <SPAN class="operator token">=</SPAN> <SPAN class="token function">FeatureSetByName</SPAN><SPAN class="punctuation token">(</SPAN>$map<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"B"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">var</SPAN> C <SPAN class="operator token">=</SPAN> <SPAN class="token function">Intersects</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">Buffer</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'feet'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token function">FeatureSetByName</SPAN><SPAN class="punctuation token">(</SPAN>$map<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"A"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> C <SPAN class="keyword token">in</SPAN> B<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN><SPAN class="keyword token">return</SPAN> C<SPAN class="punctuation token">.</SPAN>ID<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>How do I take the field from the buffered layer C and put it into layer B?