borchert / OGP2

Open Geoportal v2
http://opengeoportal.org
1 stars 2 forks source link

Handling Feature Services from ArcGIS Online/Server #4

Closed krdyke closed 9 years ago

krdyke commented 9 years ago

With Esri Open Data and Arc Online, a lot of providers will likely use Feature Services. What's the best way to handle them in OGP?

For example: http://services.arcgis.com/afSMGVsC7QlRK1kZ/arcgis/rest/services/Open_Rental_Licenses/FeatureServer/0

cheetah90 commented 9 years ago

It's definitely doable using OpenLayers. Although it does not provide direct API, we can work-around that by requesting geoJSON and converting on the fly and visualizing the data. http://gis.stackexchange.com/questions/58765/how-to-display-vectors-in-arcgis-json-format-in-openlayers

cheetah90 commented 9 years ago

Hi Kevin,

I've written the code that does the job - requesting data from Esri's Feature Server, converting from Esri JSON to GeoJSON and visualizing using OpenLayer.Layer.Vector. See the demo here. http://cheetah90.github.io/esriFeatureServicePreview/

It should be super straightforward to merge the code into the main OGP branch. I just have to come up with all the switch ... case clause the enumerate all data type.

Will do that after 2 weeks. This week is for my defense and next week is for AAG stuff.

Thanks, Allen

krdyke commented 9 years ago

For querying FeatureServices, use the following parameters in the request URL:

where=1=1
outSR=4326 

Also, although I'm not sure if it's always the case, for ArcGIS.com feature services it seems that you can specify f=geojson and not have to do the conversion yourself. You may want to add a try...catch where you first take a shot at requesting f=geojson, and if you get a 400 error, fall back to f=json

One last note. It may be that outSR should be set to 3857 for Web Mercator instead.

Let's circle back to this in May!

cheetah90 commented 9 years ago

JSONP is able to catch the 400 errors. http://stackoverflow.com/questions/2067472/what-is-jsonp-all-about

So I used the Timeout trick. http://stackoverflow.com/questions/1002367/jquery-ajax-jsonp-ignores-a-timeout-and-doesnt-fire-the-error-event

It works for now. But the value for Timeout will be very sensitive.