Select to view content in your preferred language

Using WCF service on esrilayerfeatures using JSON Format

1006
5
04-09-2013 11:35 PM
ChuaSzu_Kun
Emerging Contributor
Hi guys, i currently working on a project on Geo-spatial heatmap and it require web services to function.I was able to generate similar JSON format require for esrilayerfeature for the heatmap to consume. But it unable to display anything. I wanted to ask is my JSON Format wrong or is there a format that is required for esri to consume the service? This is my above code of JSON format that i generate using WCF service C#.

{
"displayFieldName": "NAME",
"fieldAliases": {
    "NAME": "NAME"
},
"geometryType": "esriGeometryPoint",
"spatialReference": {
    "wkid": 3414
},
"features": [
    {
        "attributes": {
            "NAME": "xxx Clinic"
        },
        "geometry": {
            "x": 27753.7308999998,
            "y": 29379.7284999993
        }
    },
    {
        "attributes": {
            "NAME": "xxx1 Clinic"
        },
        "geometry": {
            "x": 30292.2024999997,
            "y": 33825.7929999996
        }
    },
    {
        "attributes": {
            "NAME": "xxx2 Clinic"
        },
        "geometry": {
            "x": 13907.0305000003,
            "y": 35735.6776999999
        }
    }
]
}

This is the line which i use to execute the JSON format using Wcf Service using IIS localhost.

POIFeatureLayer = new esri.layers.FeatureLayer("http://localhost/RoadWatchDummyData(Json)V7/WcfService.svc/json");
0 Kudos
5 Replies
ManojrajTeli
Deactivated User
Hello,
I don't think you can directly give json as input for feature layer object.You have to create feature set and Feature collection and that feature set you have to give to featurelayer object
see Following links Might be helpful
http://gis.stackexchange.com/questions/8791/featurelayer-creating-in-javascript-arcgis-api
http://gis.stackexchange.com/questions/34608/feature-layer-from-json-file/34621#34621
http://www.arcgis.com/home/item.html?id=6d28a606369c43fd9a6f929541ae7c93
0 Kudos
ChuaSzu_Kun
Emerging Contributor
i have create a HTTP handler to return json format but it still doesnt work.
0 Kudos
ManojrajTeli
Deactivated User
can you attach the sample json file so I can see and try something out.
0 Kudos
RahulMetangale1
Frequent Contributor
I think Javascript API needs JSONP not JSON, if you are sure your JSON is in correct format just output it as a JSONP and it should work.

-Rahul
0 Kudos
ChuaSzu_Kun
Emerging Contributor
can you attach the sample json file so I can see and try something out.

I have attach the file
0 Kudos