AnsweredAssumed Answered

How can I add fields and data in a dynamic map services or Featurelayers?

Question asked by guriguri1576 on Oct 6, 2016

i`m trying to statistics data rendering. 

Statistical data is not the mapservice data.  It is a specific statistical data that the user enters.

So I try to add the data to featurelayers.

However, because the request is rendered disappeared again whenever you pan the map.

So the graphics layer was trying to save the featureset.

However, the query speed is too slow.

 

An attempt has been made to render the dynamic layer.

But I do not know how to add custom data to a dynamic layer.

How can I add fields and data in a dynamic map services or Featurelayers?

 

help me. I'm a beginner developer ongoing projects alone.

my featurelayer rocords is 17, 300, 6000.

 

test 1 : 

 

getListLawBoundary : function(map){
var LawBoundary = {
SIDO : [],
SGG : [],
UMD : []
};

require(["esri/layers/FeatureLayer", "esri/tasks/query"
], function(FeatureLayer, Query) {
var SIDO = new FeatureLayer(map.Layers.getLayerInfo("STATISTICS").SVC_URL+'/0', {id : "SIDO",mode: FeatureLayer.MODE_AUTO});
var SGG = new FeatureLayer(map.Layers.getLayerInfo("STATISTICS").SVC_URL+'/1', {id : "SGG",mode: FeatureLayer.MODE_AUTO});
var UMD = new FeatureLayer(map.Layers.getLayerInfo("STATISTICS").SVC_URL+'/2', {id : "UMD", mode: FeatureLayer.MODE_AUTO});
map.getMap().addLayers([SIDO,SGG,UMD]);
map.addEvent('layer-add',function(e){
var query = new Query();
query.where = "1=1";
query.outFields = ["*"];
query.returnGeometry = true;
query.outSpatialReference = map.getMap().spatialReference;
e.layer.queryFeatures(query, function (featureSet) {
var resultObject = null;
_ggg = map.getGraphicLayer('select');
if(e.layer.id == "SIDO"){
for(var i = 0, length = featureSet.features.length; i < length; i++){
resultObject = featureSet.features[i];
LawBoundary.SIDO[i] = resultObject;
_ggg.add(resultObject);
}
}
else if(e.layer.id == "SGG"){
for(var i = 0, length = featureSet.features.length; i < length; i++){
resultObject = featureSet.features[i];
LawBoundary.SGG[i] = resultObject;
_ggg.add(resultObject);
}
}
else if(e.layer.id == "UMD"){
for(var i = 0, length = featureSet.features.length; i < length; i++){
resultObject = featureSet.features[i];
LawBoundary.UMD[i] = resultObject;
_ggg.add(resultObject);
}
}
});
map.getMap().removeLayer(e.layer);

});
});
return LawBoundary;
}

 

test 2 : 

 

queryTask : function (map){
var LawBoundary = {
SIDO : [],
SGG : [],
UMD : []
};

require(["esri/layers/FeatureLayer", "esri/tasks/query", "esri/tasks/QueryTask"
], function(FeatureLayer, Query, QueryTask) {
var SIDO = new QueryTask(map.Layers.getLayerInfo("STATISTICS").SVC_URL+'/0');
var SGG = new QueryTask(map.Layers.getLayerInfo("STATISTICS").SVC_URL+'/1');
var UMD = new QueryTask(map.Layers.getLayerInfo("STATISTICS").SVC_URL+'/2');
var query = new Query();
query.where = "1=1";
query.outFields = ["*"];
query.returnGeometry = true;
query.outSpatialReference = map.getMap().spatialReference;
SIDO.execute(query, function (featureSet) {
for(var i = 0, length = featureSet.features.length; i < length; i++){
LawBoundary.SIDO[i] = featureSet.features[i];
}
});
SGG.execute(query, function (featureSet) {
for(var i = 0, length = featureSet.features.length; i < length; i++){
LawBoundary.SGG[i] = featureSet.features[i];
}
});
UMD.execute(query, function (featureSet) {
for(var i = 0, length = featureSet.features.length; i < length; i++){
LawBoundary.UMD[i] = featureSet.features[i];
}
});
});

return LawBoundary;
}

Outcomes