Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have geometry data in SQL Server 2008 R2. How do I load that spatial data using the ArcGIS Javascript API?

share|improve this question

3 Answers 3

you cannot access any kind of data with any web API if that data isn't published in an ArcGIS Server map service (or WMS, or KML, etc.). Nor a sql server spatial data, neither any "classic" ArcGIS data (shapefile, featureclass inside a geodatabase, etc). you have to setup an mxd project with that data loaded (you can load spatial data from sql server) and then publish it as map service on ArcGIS server. all the web API (Flex, Silverlight, Javascript) work only over web available map services (in particular http REST with ArcGIS server). hope this helps

share|improve this answer
Thanks for your reply.I saw a post like this nicogis.blogspot.in/2009/07/sql-server-2008-layer.html for Silverlight api.I am looking for the same for Javasctipt api. –  SureshRajamani Mar 1 '12 at 10:20

Write a WCF service that returns a JSONP response. WCF service should return a data in following format:

    "feature": {
        "attributes": {
            "objectid": 1,
            "fdate": 932428800000,
            "resolution": 3,
            "gnis_id": null,
            "gnis_name": null,
            "lengthkm": 0.024,
            "reachcode": "11070101001016",
            "flowdir": 1,
            "wbareacomid": null,
            "ftype": 558,
            "fcode": 55800,
            "enabled": 1
        "geometry": {
            "paths": [
share|improve this answer

I don't have time to try out the specifics, but it might not be too difficult to add data retrieved from SQL Server to an graphics layer on your map. Here's a somewhat related example


Looks like the architecture is pretty sound, even though the final product may not be exactly what you're looking for.

Also, as robmyes mentioned, a more straightforward approach may be to format your data in ArcMap and publish a map service that directly references your data in SQL Server. I've played around with Query Layers (new in ArcGIS 10) and was pretty impressed. No SDE requirement!


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.