05-07-2019 05:51 AM
Hi.
I'm trying to get all features from a specific FC in a PSS service but the result is always the same: none of the features that exists are returned. It always return empty [].
$GP.edit.features.find({featureClassId: "FeatureClass1", mapStateId: 'map', featureIds: [], mapServiceId: 'a6d1-afdd-ac9a-e359'}, function(result){console.log(result.features);}, function(){console.log('Error executing action!');})
Also if I try to obtain it without $GP the result is the same:
$mapServiceManager.findMapService(mapServiceId)._featureDataset._featureClasses[pssId]._features
Any hint about this issues?
TIA
António
05-09-2019 12:52 AM - edited 05-09-2019 12:57 AM
Hi Antonio,
First of all, $GP.edit.features.find() is not used for getting all features. It is used for getting a certain feature by some ID. If you want to get all the features, you should rather use e.g. exportFeatureCollections. This code works fine for me:
$GP.services.find({ definitionName: "PersonalStorage", name: "PSS1" }, function (result1) { $GP.edit.getFeatureClassIds({ mapServiceId: result1.mapServiceId }, function (result2) { var fIds = result2.featureClassIds; //console.log("Feature Class Ids:"); //console.log(fIds); $GP.edit.features.exportFeatureCollections({ mapServiceId: result1.mapServiceId, featureClassIds: fIds }, function (res) { console.log("Features Returned:"); console.log(res); }, function (err) { console.log(err); }); }, function (err2) { console.log(err2); }); }, function (err3) { console.log(err3); });