Hello,
So I have some code that I want to use to modify the JSON of a web_map, but I'm having a hard time getting it to work.
I have a SeDF that I'm converting to a Feature Layer:
fl = sedf.spatial.to_featurelayer(title=title, gis=gis, service_name=title)
Then I add it to the web map object:
wm.add_layer(fl, renderer_properties)
From here do I need to do an update to the web map and then use the get_data() function on the now updated web map object? Because basically I only want two layers in the web map and the fl I'm adding and a county boundary layer. I've tried it both ways but neither is working.
wm_item = gis.content.get(wm_id)
wm_data = wm_item.get_data()
wm = WebMap(wm_item)
When I then go to loop through the layers the fl.id never matches the item_ids from the operational layer, frequently they have different lengths which doesnt make any sense to me they are supposed to be accessing the same thing right?
for i, layer in enumerate(wm_data['operationalLayers']):
# This is for the new Feature Layer
print(layer)
print(layer['itemId'] + ' :: ' + fl.id)
if layer['itemId'] == fl.id:
print(layer.keys())
print(layer['title'] + ' :: ' + layer['itemId'])
popup_info = layer['popupInfo']
layer['title'] = title
layer['disablePopup'] = False
layer['popupInfo']['title'] = '{Clinic_Sit}'
layer['popupInfo']['fieldInfos'][0]['visible'] = False
layer['popupInfo']['fieldInfos'][1]['label'] = 'Agency Name'
layer['popupInfo']['fieldInfos'][2]['visible'] = False
layer['popupInfo']['fieldInfos'][3]['label'] = 'Street Address'
layer['popupInfo']['fieldInfos'][9]['label'] = 'Website'
layer['popupInfo']['fieldInfos'][10]['label'] = 'Hours of Operation'
layer['popupInfo']['fieldInfos'][11]['label'] = 'Accepting New Patients'
layer['popupInfo']['fieldInfos'][12]['label'] = 'Schedule an Appointment By'
layer['popupInfo']['fieldInfos'][13]['label'] = 'Bilingual Medical Provider (Yes/No)'
layer['popupInfo']['fieldInfos'][14]['label'] = 'Bilingual Medical Provider Language'
layer['popupInfo']['fieldInfos'][15]['label'] = 'Onsite Interpretation Services (Yes/No)'
layer['popupInfo']['fieldInfos'][16]['label'] = 'Onsite Interpretation Services Language'
layer['popupInfo']['fieldInfos'][17]['label'] = 'Telehealth Interpretation Services (Yes/No)'
layer['popupInfo']['fieldInfos'][18]['label'] = 'Telehealth Interpretation Services Language'
layer['popupInfo']['fieldInfos'][19]['visible'] = False
layer['popupInfo']['fieldInfos'][20]['visible'] = False
# This disables the popups for the county feature layer so you can select the points more easily
elif layer['itemId'] == county_id:
print(str(i) + ' ' + layer['itemId'] + ' removing popups')
layer['disablePopup'] = True
else:
print(str(i) + ' ' + layer['itemId'] + ' removing layer')
wm.remove_layer(layers[i])