Under the hood: Sharing code with ArcGIS Online

Over the past few years, ArcGIS Online has become a giant hub for people to share everything “geo”.  This includes items such as maps, packages, data, services, csv files, and more recently, documents.

You might not have known that you can share code samples too.  That means if you have some Python or ArcObjects .NET code just lying around, or a new JavaScript library that you just wrote, you can upload them to the cloud and share them with the geo-world.

Apps vs Code Samples

You can upload many different types of items to the ArcGIS cloud, so it’s important to point out that “apps” are quite different from “code samples”.  Apps are generally applications such as configurable templates and solutions that you share with others. Some app items just contain URLs to apps hosted somewhere else, while others contain pre-compiled ready-to-use apps that you can download and install on your computer or device, e.g. ArcGIS for Android.

Code samples, however, are just items that you create when you upload .zip files that contain your custom code, project files and directories.

Finding Code Samples

  1. Go to the ArcGIS.com Gallery and add “type:code samples” in the search box.

  2. Now here’s the real secret! Check ON the “Show ArcGIS Desktop Content” and click the “Date” link to sort code samples with the newest on top.  Presto!

  1. Now add some keywords to refine your search.  Try these:

GeoGeek Tip: Is there an easy way to find the latest code samples that have been uploaded to ArcGIS Online? Yes! Because every custom search is just an HTTPS REST request, you can just bookmark it and refresh your browser to see the newest code samples at any time in the future.

Sharing Code Samples

  1. Log into ArcGIS Online and go to the “My Content” tab.  NOTE:  You’ll need an account to do so.

  2. Click “Add Item” and choose your .zip to upload.

    Once you get the .zip, use the “Contents” and “Language” pulldowns to specify “Code Sample” and the language the app is written in.  Go ahead and add some tags too.

Share your code: Once the item is created, use “SHARE” to share the code sample with “Everyone” in the world, or just with a Group you own.

GeoGeek Tip: Should I use ArcGIS Online or GitHub to share my code? Great question! If you are looking for a simple way to upload a .zip file and share it with your private AGO organization, and you’re not worried about version control, then ArcGIS Online might be a good way to go. However, if you want to to publicize your code, use version control and accept code contributions from the community, then GitHub is a better tool.  If you are unsure which way to go, the just add your code to ArcGIS Online and then add a link to the GitHub repository where you can manage it and accept contributions. We do this all of the time!

That’s it folks!

If you are looking for more code examples, feel free to search the samples in the SDKs or go check out our open source projects on esri.github.io.

This entry was posted in App Developers, Developer, Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

One Comment

  1. kenbuja says:

    This does work in Chrome, but not in Firefox (v 24.3.0) or IE (v 10.0.9200)? When I put “type:code samples” in the Search box, I get “Your search did not return any results.”