I'm pulling point data by lat long from my SQLServer database via webservice and creating a JSON FeatureCollection object as the webservic response. When I attempt to create a FeatureLayer from this FeatureCollection, the geometry attribute of the features becomes null, while the attribute array of each feature and the layerdefinition comes through fine. Here's a sample of my code and JSON: JSON:
{
"layerDefinition": {
"geometryType": "esriGeometryPoint",
"objectIdField": "ObjectID",
"drawingInfo": {
"renderer": {
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
205,
212,
144
],
"size": 50,
"angle": 0,
"xoffset": 0,
"yoffset": 0,
"type": "esriSMS",
"style": "esriSLSSolid",
"outline": {
"color": [
205,
212,
144
],
"width": 0,
"type": "esriSLS",
"style": "esriSLSolid"
}
}
}
},
"fields": [
{
"name": "ObjectID",
"alias": "ObjectID",
"type": "esriFieldTypeOID"
}, ...some more fields...
]
},
"featureSet": {
"features": [
{
"attributes": {
"ObjectID": 1,...more attributes...
},
"geometry": {
"type": "point",
"x": -8242964.882933755,
"y": 5071902.135513675,
"spatialReference": {
"wkid": 102100
}
}
},
Code:
function onGetFeatureJsonReturn(msg) {
var featureCollection = JSON.parse(msg.d);
var featureLayer = new esri.layers.FeatureLayer(featureCollection, {
id: 'HourlyDataLayer'
});
map.addLayers([featureLayer]);
}
No comments:
Post a Comment