Add Feature Service Item to WebMap

2027
4
Jump to solution
06-06-2017 06:55 AM
irishadar
New Contributor III

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-di...

but it is not working.

Does anyone knows what am I doing wrong?

thanks iris

This is the whole script:

from arcgis.gis import *
import os
import json
from IPython.display import display
gis = GIS("URL","USER","PW")
surServcie_properties={'title':'testing iris item',
'description':'testing adding new item by script',
'tags':'python,test','type':'Feature Service','url':'http://HOSTNAME/FOLDER/rest/services/TestSurIris/FeatureServer'}

surServcie_item = gis.content.add(item_properties=surServcie_properties,
thumbnail = None)

web_map_dict = dict()
with open("C:\\Temp\\base.json","r") as file_handle:
web_map_dict = json.load(file_handle)
web_map_dict['operationalLayers'][0]['itemId'] = surServcie_item.itemid
web_map_dict['operationalLayers'][0]['layerType'] = "ArcGISFeatureServiceLayer"
web_map_dict['operationalLayers'][0]['title'] = surServcie_item.title
web_map_dict['operationalLayers'][0]['url'] = surServcie_item.url
web_map_dict['operationalLayers'][0]['layerDefinition'] = '{"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"}}}}}'
display(web_map_dict)

web_map_properties = {'title':'SurveyColector test map',
'type':'Web Map',
'snippet':'This map to be used in the collector ',
'tags':'python',
'text':json.dumps(web_map_dict)}
# Call the add() with web map item's properties and content.
web_map_item = gis.content.add(web_map_properties)
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AtmaMani
Esri Contributor

A couple of things to note and try:

  • web_map_dict['operationalLayers'][0]['url'] = surServcie_item.url + "/" + layer_id

The URL in operationalLayers dictionary should point to a layer in FeatureService. You are pointing to the service directly. Your url should end with layer id, such as 0,1,2 etc

  • What is the geometry of your feature layer? The template shown here and what you have used is for points. If your geometry is lines or polygons, you must appropriately differently symbology. If you are unsure what to you, do not specify the 'drawingInfo' dictionary. The webmap will pick the defaults from your feature service and render it.

View solution in original post

4 Replies
AtmaMani
Esri Contributor

A couple of things to note and try:

  • web_map_dict['operationalLayers'][0]['url'] = surServcie_item.url + "/" + layer_id

The URL in operationalLayers dictionary should point to a layer in FeatureService. You are pointing to the service directly. Your url should end with layer id, such as 0,1,2 etc

  • What is the geometry of your feature layer? The template shown here and what you have used is for points. If your geometry is lines or polygons, you must appropriately differently symbology. If you are unsure what to you, do not specify the 'drawingInfo' dictionary. The webmap will pick the defaults from your feature service and render it.
irishadar
New Contributor III

thank you,

You're right !!!

iris

0 Kudos
ModyBuchbinder
Esri Regular Contributor

אם את זוכרת אני אמרתי לך באיזה שלב שאת קוראת ל mapservice במקום ל feature service רק שלא ידעתי את הסינטקס המדויק לעשות זאת

מודי

0 Kudos
irishadar
New Contributor III

כן נכון שמתי לב .

תודה

בתאריך 13 ביוני 2017 07:30,‏ "Mody Buchbinder" <geonet@esri.com> כתב:

GeoNet <https://community.esri.com/?et=watches.email.thread>

Re: Add Feature Service Item to WebMap

reply from Mody Buchbinder

<https://community.esri.com/people/modybsystematics-co-il-esridist?et=watches.email.thread>

in ArcGIS API for Python - View the full discussion

<https://community.esri.com/message/693335?commentID=693335&et=watches.email.thread#comment-693335>

0 Kudos