Trying to get a graphics layer that was created from JSON (using the whole webmap to JSON workflow) from one map in APRX to another map using arcpy.
I've tried this:
myLayer <SPAN class="operator token">=</SPAN> map1<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"myLayer"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
map2<SPAN class="punctuation token">.</SPAN>addLayer<SPAN class="punctuation token">(</SPAN>myLayer<SPAN class="punctuation token">)</SPAN>
map2<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The layer now shows up in the layer list. But I can't see it in the map. So I tried this:
layerDef <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>loads<SPAN class="punctuation token">(</SPAN>Web_Map_as_JSON<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="operator token"><</SPAN>index of layer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">]</SPAN>
map2<SPAN class="punctuation token">.</SPAN>addLayer<SPAN class="punctuation token">(</SPAN>map1<SPAN class="punctuation token">.</SPAN>listLayer<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"myLayer"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
map2<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"myLayer"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>updateLayerFromJSON<SPAN class="punctuation token">(</SPAN>layerDef<SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Everything runs without errors. I just don't get the added layer to display. Any suggestions?