adds basic getFeatureLayerJSON functionality

This commit is contained in:
Andy Gup 2015-03-17 11:57:03 -06:00
parent 0a320689e2
commit 940bd4ab5c

View File

@ -79,12 +79,13 @@ define([
},
/**
* Overrides a feature layer.
* Overrides a feature layer. Call this AFTER the FeatureLayer's 'update-end' event
* @param layer
* @param callback {boolean, String} Traps whether or not the database initialized
* @param options Optional configuration Object. Added @ v2.5
* @returns deferred
*/
extend: function(layer,callback)
extend: function(layer,callback,options)
{
var self = this;
@ -106,6 +107,11 @@ define([
layer._queryAttachmentInfos = layer.queryAttachmentInfos;
layer._deleteAttachments = layer.deleteAttachments;
this._getFeatureLayerJSON(layer.url,function(success,result){
console.log("FEATURE LAYER SUCCESS " + success);
console.log("FEATURE LAYER JSON: " + JSON.stringify(result));
});
/*
operations supported offline:
1. add a new attachment to an existing feature (DONE)
@ -438,7 +444,7 @@ define([
/**
* Converts an array of graphics/features into JSON
* @param features
* @param updateEndEvent
* @param updateEndEvent The layer's 'update-end' event
* @param callback
*/
layer.convertGraphicLayerToJSON = function(features,updateEndEvent,callback){
@ -1111,6 +1117,31 @@ define([
},
/**
* Retrieves f=json from the feature layer
* @param url FeatureLayer's URL
* @param callback
* @private
*/
_getFeatureLayerJSON: function(url,callback){
require(["esri/request"],function(esriRequest){
var request = esriRequest({
url: url,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
request.then(function(response) {
console.log("Success: ", response);
callback(true,response);
},function(error) {
console.log("Error: ", error.message);
callback(false,error.message);
});
})
},
/**
* Executes the _applyEdits() method
* @param layer