To do some advanced web map printing, I used the python script in the "Basic web map printing/exporting using arcpy.mapping" tutorial. In the python script, there is a block of code to remove all layers in the map that are service layers:
for lyr in arcpy.mapping.ListLayers(mxd, data_frame=df): if lyr.isServiceLayer: arcpy.mapping.RemoveLayer(df, lyr)
This mostly works, but I am finding that it does not seem to remove services that are feature services. Is there any reason for this? How can I get it to remove all services from the map, including feature services?
Thanks.
What version of ArcGIS are you using? I ask because there were some changes, I would argue bugs, with how serviceProperties behave differently in ArcGIS 10.3 than ArcGIS 10.2.2. Not sure if that could affect isServiceLayer as well or not.
We are using ArcGIS 10.3.
As a work-around I am using the isRasterizingLayer property to remove the service layers that are not being removed by the isServiceLayer block above, but it seems a bit of a hack.