You submit a query to the ArcGIS REST API interface of your ArcGIS Online organization. There is one AGOL organization that is publicly available that is used by Esri for demos.
http://services1.arcgis.com/hLJbHVT9ZrDIzK0I/ArcGIS/rest/services
Here is a feature service with a layer:
http://services1.arcgis.com/hLJbHVT9ZrDIzK0I/ArcGIS/rest/services/EQMagGt4/FeatureServer/0
It is just about submitting a query. In here, I select all earthquake points with a magnitude larger than 5.5:
http://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/EQMagGt4/FeatureServer/0/query?where=MAG+%3E+5.5&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&multipatchOption=&maxAllowableOffset=&geometryPrecision=&outSR=4326&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=pgeojson&token=
Remember to set up the proper output spatial reference as well as to choose GeoJSON for your output data format.
Here is a GeoJSON saved as a gist on GitHub.
Your two friends are geojsonlint for validating GeoJSON and geojsonio for interactive review of the GeoJSON and map plotting.
There are cool tools built by Esri, available on GitHub for plotting GeoJSON with JS API.
Best Answer
You can convert the geoJson to Graphics and add them to the map pretty easily (you can probably even cast to
FeatureLayer
). Esri has created a nice library to convert between geojson and esri json format, it's called geojson-utils. I have used it in the past and it works pretty nicely.The following code worked for me:
EDIT:
As pointed out below by @BjornSvensson, looks like the
goejson-utils
project is not actively maintained, instead have a look at Terraformer or arcgis-to-geojson.