Select to view content in your preferred language

How to Share a Feature Layer as a Web Layer using ArcGIS Pro SDK?

544
8
3 weeks ago
AbhijeetNandeshwar1
Occasional Contributor

Hello everyone,

I’m trying to replicate the “Share As Web Layer” functionality (shown in the screenshot) using the ArcGIS Pro SDK.

Here are my questions:

  1. Is there a direct API in ArcGIS Pro SDK to share a feature layer (or raster layer) as a web layer to ArcGIS Online / Enterprise?

  2. If not, is there any workaround through the SDK that mimics the desktop workflow (right-click → Share As Web Layer)?Share as a web layer.png

Any insights, documentation links, or code examples would be very helpful.

Thanks in advance!

@UmaHarano , @Wolf 

8 Replies
AbhijeetNandeshwar1
Occasional Contributor

Hello,

@UmaHarano , @Wolf , @GKmieliauskas ,

Please could someone help me with this query?
It would be a great help if anyone could provide some insights.

Regards,
Abhijeet

0 Kudos
UmaHarano
Esri Regular Contributor

@AbhijeetNandeshwar1 

I am not aware of a way to accomplish this with the API. 
I recommend posting this request in the Pro ideas site for the API support.

Wolf
by Esri Regular Contributor
Esri Regular Contributor

I am trying to find the script / GP tool that can be used to 'share' or 'publish' a feature layer as a web layer.  Until then you can at least present your users programmatically with the 'share feature layer as web layer' dockpane using this snippet:

IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_sharing_SharingAsWebLayerPaneBtn");
if ((wrapper is ICommand command) && command.CanExecute(null))
            command.Execute(null);

 

0 Kudos
AbhijeetNandeshwar1
Occasional Contributor

Hello @Wolf ,

Thank you for your insights. I tried this workflow, but I want to autopopulate the Geoprocessing tool through code. It doesn’t achieve the desired result.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

After some digging we found this:
An overview of the Publishing toolset—ArcGIS Pro | Documentation
which indicates that it is possible to publish a feature layer as a web layer.  It appears that to accomplish this is very complicated.  I will try to publish a sample that publishes a feature layer as a web layer.  I'll put the sample on this thread as well - if i can get it to work.

AbhijeetNandeshwar1
Occasional Contributor

Thank you @Wolf , I am waiting for you to provide me with a example.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry about the delay we started to certify 3.6... 
I attached a sample ArcGIS Pro Add-in project that includes the python script used to publish a feature layer as a web layer.   Because the code is using ExecuteToolAsync to run the python script the script can utilize the existing ArcGIS Pro portal connection eliminating the need to passing user name/ password to the script.
here is the sample's readme:

  1. This solution file includes an example python script named MySharing.pyt which is included as 'Content' (Build action) in the add-in.
  2. The python script is stored in the .\Toolboxes\toolboxes folder and when this add-in is loaded in ArcGIS Pro the python script is available a script tool under the ArcGIS Pro Geoprocessing toolbox.
  3. You can run the python script from the Geoprocessing toolbox as shown here.
     

    Screen1.pngScreen2.pngScreen3.pngScreen4.pngScreen5.pngScreen6.png

    4. You can also run the python script from code as implemented in the 'Publish as Web Layer' button under the 'Custom Publishing' tab (RunPyScriptButton.cs).
    Screen7.pngScreen8.pngScreen9.png

     


     

     


     

     

     


     

     


     

     

JeromeHaaland
Frequent Contributor

Wolf,

Thank You for the reply above.  Your Python script works well.

It does seem like the workflow you scripted in Python would be practical as a C# Method in the ArcGIS Pro SDK.  And it seems like there would be a huge number of customers that could use this functionality.

Yes... I know... I could suggest this as an "idea".

It is certainly possible that I am missing something... but it does not appear possible to load a tpkx file to ArcGIS Online with Python.

The tpkx files appear to be more advantageous to my customers because they can be loaded to a device and read natively from the Field Maps app.  That is extremely advantageous for several reasons.  There are still many cellular dead spots (and more extremely slow spots) in the world.  Satellite cellular connections will soon change this to some extent... however, this data will always need a lot of bandwidth... which means that for quite some time it will be best to store the mapping data on a device.

Again... Thank You for your work.





0 Kudos