[GIS] How to use the ESRI JS API to map SQL Server Spatial Types without ArcGIS Server

arcgis-javascript-apisql server

I have heard of people using the ESRI Javascript API to create webmaps with spatial data from SQL Server or other RDBMS's. From what I can tell, they are not using ArcGIS Server as a middleware. In particular, I recently heard of a company that uses a SQL Server database with spatial types and Entity Framework to link the database to the app, but then they are using the ESRI JS API on the front end to render the data.

This is something that really interests me as I have worked with SQL Server, Entity Framework, ASP.Net, and the JS API separately and I do not have access to ArcGIS Server. Does anyone know of a particular architecture or workflow for simply using the JS API as a front end for a non ESRI backend?

Best Answer

Just to add more detail, when you create a service to return JSON from SQL Server, you would then use the feature collection object to create a new layer on the map. From javascript, you would take the attributes and the spatial component returned from your service and format it to the Esri geometry format to create the feature collection.

The closer your server returns a format like the Esri format, the less parsing you have to do on the client. JSON is pretty easy to parse once you get the hang of it.

The feature collection displayed would be a graphic layer on the map. You could have an Esri or other public base map underneath. One issue you will have is performance when you start approaching thousands of features -- particularly if they have a lot of vertices per geometry. Feature services on ArcGIS server return a max 1000 records by default.

As far as calculations, you should do them with SQL (it has spatial extensions) in the database before returning them to the client. If you are trying to display hundreds of thousands of features though, you are going to have to use Geoserver or UMN Mapserver and return them as WMS or a tiled service -- you can't display that many graphics in the browser.

Check out this sample where a layer is created from a Flickr data feed. No ArcGIS Server involved -- http://developers.arcgis.com/en/javascript/jssamples/fl_featureCollection.html