Hi’
I have followed the example notebook “Publish WebMap” and tried to add Feature Service Item to my web map.
The Script works fine only the Layer does not show in the map.
When I add the same layer Item manually it was working fine.
I have followed this suggesting
your_web_map_obj['operationalLayers'][0]['layerDefinition']['drawingInfo']['renderer']
from URL :
https://community.esri.com/thread/193550-web-map-created-with-python-api-and-feature-services-not-displaying-features#comment-680511
but it is not working.
Does anyone knows what am I doing wrong?
thanks iris
This is the whole script:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN>
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> json
<SPAN class="keyword token">from</SPAN> IPython<SPAN class="punctuation token">.</SPAN>display <SPAN class="keyword token">import</SPAN> display
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"URL"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"USER"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"PW"</SPAN><SPAN class="punctuation token">)</SPAN>
surServcie_properties<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'testing iris item'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'description'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'testing adding new item by script'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'tags'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'python,test'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'type'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'Feature Service'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'url'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2FHOSTNAME%2FFOLDER%2Frest%2Fservices%2FTestSurIris%2FFeatureServer" target="_blank">http://HOSTNAME/FOLDER/rest/services/TestSurIris/FeatureServer</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">}</SPAN>
surServcie_item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>add<SPAN class="punctuation token">(</SPAN>item_properties<SPAN class="operator token">=</SPAN>surServcie_properties<SPAN class="punctuation token">,</SPAN>
thumbnail <SPAN class="operator token">=</SPAN> None<SPAN class="punctuation token">)</SPAN>
web_map_dict <SPAN class="operator token">=</SPAN> dict<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">with</SPAN> open<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"C:\\Temp\\base.json"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"r"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> file_handle<SPAN class="punctuation token">:</SPAN>
web_map_dict <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>file_handle<SPAN class="punctuation token">)</SPAN>
web_map_dict<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</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><SPAN class="string token">'itemId'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> surServcie_item<SPAN class="punctuation token">.</SPAN>itemid
web_map_dict<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</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><SPAN class="string token">'layerType'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ArcGISFeatureServiceLayer"</SPAN>
web_map_dict<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</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><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> surServcie_item<SPAN class="punctuation token">.</SPAN>title
web_map_dict<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</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><SPAN class="string token">'url'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> surServcie_item<SPAN class="punctuation token">.</SPAN>url
web_map_dict<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</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><SPAN class="string token">'layerDefinition'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="string token">'{"drawingInfo":{"renderer":{"type":"simple","label":"","description":"","symbol":{"color":[133,0,11,255],"size":4,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS","style":"esriSMSCircle","outline":{"color":[0,0,0,255],"width":1,"type":"esriSLS","style":"esriSLSSolid"}}}}}'</SPAN>
display<SPAN class="punctuation token">(</SPAN>web_map_dict<SPAN class="punctuation token">)</SPAN>
web_map_properties <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'SurveyColector test map'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'type'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'Web Map'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'snippet'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'This map to be used in the collector '</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'tags'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'python'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'text'</SPAN><SPAN class="punctuation token">:</SPAN>json<SPAN class="punctuation token">.</SPAN>dumps<SPAN class="punctuation token">(</SPAN>web_map_dict<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token"># Call the add() with web map item's properties and content.</SPAN>
web_map_item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>add<SPAN class="punctuation token">(</SPAN>web_map_properties<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>