I am trying to 'add a layer from URL' to my webmap using an API from OpenStreetMap (OSM). OSM recommends using Overpass Turbo, which is a web based data mining tool designed for their system: https://overpass-turbo.eu/
Overpass Turbo allows the user to run queries using keywords which are defined here: Map Features. For example, I would like to find cities in Haiti so the query is written as:
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“place=city in haiti”
*/
[out:json][timeout:25];
// fetch area “haiti” to search in
{{geocodeArea:haiti}}->.searchArea;
// gather results
node["place"="city"](area.searchArea);
// print results
out geom;
This query runs successfully in Overpass Turbo and returns points corresponding to cities in Haiti. I then click the Export button which opens a pop-up with several options, none of which work with "Add layer from URL" in AGOL. For example, I tried selecting "raw data directly from Overpass API" which opens a new browser tab with the data. I copied this URL and tried adding it as a layer as a geojson, but I get an error: "Unable to add layer. The layer cannot be added to the map." For reference, I am able to download the data and add it as a hosted layer but I am trying to do this directly from a URL so I don't have to host copies of the OSM data.
I have tried troubleshooting this on chatGPT and it seems like the issue maybe json vs geojson formatting. I created a python notebook and tried writing some code to correct this but have been unsuccessful. At this point I feel like I'm getting too far down a rabbit hole for something that should be fairly straight forward.
Is there a way to use Overpass Turbo to create a URL which can be read into geojson layer in AGOL?