Hello Everyone,
I need a help on rendering. I am working on following workflow and achieved half way mark but stuck at below point:
1) using arcobjects i am able to convert featureclass to JSON and finally store as a BLOB in oracle database.
2) Now , over the web module i am able to get back the data as a JSON but unable to render this back to feature class to add as a layer on web
[I want this to be done using arcgis api's for javascript]
Any suggestions would be highly appreciated.
Thanks and Regards
Solved! Go to Solution.
This is the most relevant example:
This is the most relevant example:
Thanks Josh for your quick reply!! I believe i want something different than this . As i said i have converted complete feature class to JSON and store as a BLOB. Now , on the web when i am retrieving this BLOB and converting back to JSON i am getting following output : SO HOW CAN I CONVERT IT BACK TO FEATURE CLASS AND ADD AS A LAYER USING ARCGIS JAVASCRIPT???
{\"displayFieldName\":\"\",\"fieldAliases\":{\"OBJECTID\":\"OBJECTID\",\"APPL_SI_NO\":\"Application Site Number\",\"CREATE_BY\":\"Created By\",\"CREATE_DT\":\"Created Date\",\"LST_MDF_BY\":\"Last Modified By\",\"LST_MDF_DT\":\"Last Modified Date\",\"SYSTEM_ID\":\"System ID\",\"SGDP_AREA\":\"SGDP AREA\",\"GLOBALID\":\"GLOBALID\",\"Shape_Length\":\"Shape_Length\",\"Shape_Area\":\"Shape_Area\"},\"geometryType\":\"esriGeometryPolygon\",\"spatialReference\":{\"wkid\":3414,\"latestWkid\":3414},\"fields\":[{\"name\":\"OBJECTID\",\"type\":\"esriFieldTypeOID\",\"alias\":\"OBJECTID\"},{\"name\":\"APPL_SI_NO\",\"type\":\"esriFieldTypeString\",\"alias\":\"Application Site Number\",\"length\":25},{\"name\":\"CREATE_BY\",\"type\":\"esriFieldTypeString\",\"alias\":\"Created By\",\"length\":100},{\"name\":\"CREATE_DT\",\"type\":\"esriFieldTypeDate\",\"alias\":\"Created Date\",\"length\":8},{\"name\":\"LST_MDF_BY\",\"type\":\"esriFieldTypeString\",\"alias\":\"Last Modified By\",\"length\":100},{\"name\":\"LST_MDF_DT\",\"type\":\"esriFieldTypeDate\",\"alias\":\"Last Modified Date\",\"length\":8},{\"name\":\"SYSTEM_ID\",\"type\":\"esriFieldTypeString\",\"alias\":\"System ID\",\"length\":20},{\"name\":\"SGDP_AREA\",\"type\":\"esriFieldTypeDouble\",\"alias\":\"SGDP AREA\"},{\"name\":\"GLOBALID\",\"type\":\"esriFieldTypeGlobalID\",\"alias\":\"GLOBALID\",\"length\":38},{\"name\":\"Shape_Length\",\"type\":\"esriFieldTypeDouble\",\"alias\":\"Shape_Length\"},{\"name\":\"Shape_Area\",\"type\":\"esriFieldTypeDouble\",\"alias\":\"Shape_Area\"}],\"features\":[{\"attributes\":{\"OBJECTID\":1,\"APPL_SI_NO\":\"0000/3916/0001\",\"CREATE_BY\":\" \",\"CREATE_DT\":-2209161600000,\"LST_MDF_BY\":\" \",\"LST_MDF_DT\":-2209161600000,\"SYSTEM_ID\":\" \",\"SGDP_AREA\":null,\"GLOBALID\":\"{9B397F6B-20E4-4146-99BB-1CB9264E49EB}\",\"Shape_Length\":18820.957758541444,\"Shape_Area\":13935394.100851806},\"geometry\":{\"rings\":[[[13204.61360000167,23092.193700008094],[18754.114800002426,26549.260000005364],[21217.413772959262,23061.559098981321],[13204.61360000167,23092.193700008094]]]}},{\"attributes\":{\"OBJECTID\":2,\"APPL_SI_NO\":\"1997/0335/0001\",\"CREATE_BY\":\" \",\"CREATE_DT\":-2209161600000,\"LST_MDF_BY\":\" \",\"LST_MDF_DT\":-2209161600000,\"SYSTEM_ID\":\" \",\"SGDP_AREA\":null,\"GLOBALID\":\"{547D35A7-6749-4C4E-B17C-96FB8E21A6E4}\",\"Shape_Length\":28665.246133473382,\"Shape_Area\":31852909.191307254},\"geometry\":{\"rings\":[[[49097.27291581966,37636.009742863476],[54507.458400003612,42378.984600001946],[53737.337799999863,29928.675600003451],[49097.27291581966,37636.009742863476]]]}}]}
Thanks and Regards
I would suggest following the example I posted.
featureCollection.featureSet.features is an array built from the contents of your database
featureCollection.layerDefinition will need to be modified to match your data (geometry type, field list...). This can be built programmatically from your features if you want to make it generic.
Use the chrome debug tools to inspect the example for formats. You may need to change the format of what you're storing in the database currently. Also, each of your records will need a unique OBJECTID, that's messed me up in the past.
Finally, if you're fetching from a database and are presenting this data using some server side script, then you might consider creating a GeoRSS or CSV service. There's already support for these formats in the API and it might be an easier approach than what you're attempting.
GeoRSSLayer | API Reference | ArcGIS API for JavaScript
CSVLayer | API Reference | ArcGIS API for JavaScript
Best of luck
Thanks Again Josh!!
I am working on it and will share the feedback once it is accomplished..
Regards
Hi Josh,
Sorry for late acknowledgment but your suggestion works perfectly fine. Thanks
Here is the code to help other developers: [featSafeguardDevt contains the features coming from ajax call to JSON service stored in database]
//// ---------------Feature Layer Method----------------------------
lsSafeguardLayer.clear;
map.graphics.clear;
map.graphics.refresh();
//now go into each graphic layer and clear it
var graphicLayerIds = map.graphicsLayerIds;
var len = graphicLayerIds.length;
for (var i = 0; i < len; i++) {
var gLayer = map.getLayer(graphicLayerIds);
//clear this Layer
map.removeLayer(gLayer);
}
var extent = "";
for (var loop = 0; loop < featSafeguardDevt.length; loop++) {
var featNewSite = featSafeguardDevt[loop];
if (featNewSite.attributes.APPL_SI_NO == appsino) {
//create a feature collection for the rejected and selected site no. on dashboard
var featureCollection = {
"layerDefinition": null,
"featureSet": {
"features": [featNewSite],
"geometryType": jsonSafeguardDevt.geometryType
}
};
featureCollection.layerDefinition = {
"geometryType": jsonSafeguardDevt.geometryType,
"objectIdField": "OBJECTID",
"fields": jsonSafeguardDevt.fields,
"spatialReference": jsonSafeguardDevt.spatialReference,
"displayFieldName": jsonSafeguardDevt.displayFieldName
};
//create a feature layer based on the feature collection
lsSafeguardLayer = new esri.layers.FeatureLayer(featureCollection, {
id: 'lsSafeguardLayer'
});
lsSafeguardLayer.setEditable(false);
map.addLayer(lsSafeguardLayer);
lsSafeguardLayer.refresh();
if (lsSafeguardLayer.graphics[0]._extent != "")
lsSafeguardLayer.graphics[0]._extent.spatialReference = map.spatialReference;
map.setExtent(lsSafeguardLayer.graphics[0]._extent);
break;
}
}
//// ---------------Feature Layer Method END----------------------------
Thanks and Regards