0

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

3 Answers 3

1

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": [
                [
                    [
                        -95.9899452281111,
                        38.1345878074741
                    ],
                    [
                        -95.9898896947778,
                        38.1344644074744
                    ],
                    [
                        -95.9899164947778,
                        38.1343866074744
                    ]
                ]
            ]
        }
    }
}
]
0

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

2
  • 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. Commented Mar 1, 2012 at 10:20
  • I had to downvote this for obvious reasons. Data published in via an ArcGIS Server service is easier to use, but it is not the only way to get data to your map service. This is older, but it can still be a resource for newbies. There are extensions to ESRI JS API as well as other types of Layers that would be able to use data from different sources. Ever hear of JSON?
    – Branco
    Commented Jun 16, 2015 at 0:24
0

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

http://boomphisto.blogspot.com/2011/07/simple-maps-using-geojson-and-tile5.html

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!

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_is_a_query_layer/00s50000000n000000/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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