|
POST
|
I ended up doing a manual rest call, but why would the cost work without that call and then suddenly break? Now it's working fine, so I don't want to make any more changes to it.
... View more
02-14-2023
01:08 PM
|
0
|
0
|
747
|
|
POST
|
Good Day I posted a similar question under the ArcGIS REST JS section. I'm running a query by username to try and fetch the folders that are under a user account, where is the function: private getArcGISFolders(): Promise<ArcGISItem[] | Error>{
return new Promise((r, j) => {
const query = new PortalQueryParams({
query: `username: ${this._portal.user.username}`,
});
this._portal.queryUsers(query).then((queryResults) => {
this._folders = [];
if (!Array.isArray(queryResults.results)) {
j();
} else {
try {
queryResults.results?.forEach((folder) => {
console.log('Folder');
console.log(folder);
this._folders.push({
id: folder.id,
title: folder.title
})
})
} catch(error) {
j(error);
}
}
r(this._folders);
}).catch((error) => {
console.log('Query User - Error');
console.log(error);
j(error);
})
})
} A couple of weeks ago this function was working fine, and I was getting the folders that a user had under their ArcGIS Account, and now I'm not. I noticed in the response that "access" is set to "public", which I think is what is causing the problem. 1. Is there a way to properly modify the access of the queryUser function? 2. Is this the right way to query for folders from ArcGIS? Thanks
... View more
02-07-2023
12:39 PM
|
0
|
2
|
824
|
|
POST
|
Good Day I have the following function which is running query by username to get the folders that a user has access to. This function worked a couple of weeks ago, and would return me the list, and now it's running nothing. private getArcGISFolders(): Promise<ArcGISItem[] | Error>{
return new Promise((r, j) => {
const query = new PortalQueryParams({
query: `username: ${this._portal.user.username}`,
});
this._portal.queryUsers(query).then((queryResults) => {
this._folders = [];
if (!Array.isArray(queryResults.results)) {
j();
} else {
try {
queryResults.results?.forEach((folder) => {
console.log('Folder');
console.log(folder);
this._folders.push({
id: folder.id,
title: folder.title
})
})
} catch(error) {
j(error);
}
}
r(this._folders);
}).catch((error) => {
console.log('Query User - Error');
console.log(error);
j(error);
})
})
} 1. Is this the right way to query for folders? 2. What would prevent this query from returning the folders Thanks
... View more
02-06-2023
08:04 AM
|
0
|
0
|
682
|
|
POST
|
Good Day I've noticed that for some of my map, the legend on the Print Template is missing, and I don't know why. ex: Compared to others: All maps use the same "UniqueRenderer", which has ~200 settings in it, and on the two maps shown, they both forgo using valueExpressions', unlike all the other maps. So what causes the legend to show up? For the two maps shown, they're set up virtually the same way, the only difference would be the field they reference, but both use a string field. Thanks
... View more
12-22-2022
02:47 PM
|
0
|
1
|
578
|
|
POST
|
The other question I should ask, is this even recommended or practical to do? We could have layers with 100k+ features in them, and we'd want to perform the same kind of step, is there anyway to do this at scale and with minimal latency?
... View more
11-17-2022
02:26 PM
|
0
|
0
|
1667
|
|
POST
|
Yes, they exist, the features all contain v1 -> v4, v1 is always a number from 0 - 100 in string form, and I'm doing feature.setAttribute('v1', "SUPERRANDOMSET"). After that logic runs v1 is still "0" - "100", when I expect it to be "SUPERRANDOMSET". Could there be a problem running the update on a layer that was created from ArcGIS Online? I've been able to do this with client side graphics when I build them manually.
... View more
11-17-2022
12:53 PM
|
0
|
0
|
1692
|
|
POST
|
Good Day Thanks for the reply, I'm using a Hosted Feature Layer, please see this more complete example: addGISFeatureAttributes(layer: FeatureLayer) {
return new Promise((r) => {
console.time('correlationLook10k');
this.queryAllFeatures(layer).then((features: Graphic[]) => {
this.grabData().then(() => {
features.forEach((feature, idx) => {
const matchedFeature =
this.data.find(d => d.x === feature.attributes.x)
if (matchedFeature) {
const value1 =
matchedFeature?.find(m => m.type === 'v1').value ?? 0;
const value2 =
matchedFeature?.find(m => m.type === 'v1').value ?? 0;
const value3 =
matchedFeature?.find(m => m.type === 'v1').value ?? 0;
feature.setAttribute('v1', Number(value1));
feature.setAttribute('v2', Number(value2));
feature.setAttribute('v3', Number(value3));
feature.attributes.v4 = Number(value3);
}
})
layer.applyEdits({updateFeatures: features}).then((updateResults) => {
console.log('Update Results');
console.log(updateResults);
const query = {
where: '1=1',
outFields:['*'],
returnGeometry: true,
maxRecordCountFactor: 5
}
const objectIds = [];
updateResults.updateFeatureResults.forEach((item) => {
objectIds.push(item.objectId);
});
console.log('Object Ids');
console.log(objectIds);
layer.queryFeatures(query).then((results) => {
console.log(results.features.length, "features have been added.");
console.timeEnd('correlationLook10k');
r(results);
}).catch((error) => {
console.log('Query Feature Error');
console.log(error);
})
}).catch((error) => {
console.log('Upload Error');
console.log(error);
})
});
});
});
}
showPortalFeatureLayerByYear(year: number = new Date().getFullYear()) {
let layerId = "SOME PORTAL ID"
this._layers = [];
new FeatureLayer({
portalItem: {
id: layerId,
},
outFields: ['*']
}).load().then((layer) => {
this.addGISFeatureAttributes(layer).then((features: FeatureSet) => {
console.log('Features');
console.log(_.cloneDeep(features));
return new FeatureLayer({
source: features.features,
fields: features.fields,
renderer: null,
spatialReference: {
wkid: 102100
},
outFields: ["*"]
}).load().then((layer) => {
this._layers.push(layer);
this.renderHostedFeatureLayer();
})
})
})
} Should I have my new layer with v1 -> v4? This does the applyEdits, and this does the query stage. One thing I've noticed, this is slow, ~60 seconds for 10k assets, so this generally not recommended? Thanks
... View more
11-17-2022
09:57 AM
|
0
|
3
|
1711
|
|
POST
|
Good Day I already know about setAttribute, my question is how save the update so my attribute become available? this.grabData().then(() => {
this.queryAllFeatures(this._layers[0]).then((features: Graphic[]) => {
features.forEach((feature, idx) => {
const matchedFeature = this.data.find(d => d.x === feature.attributes.x)
if (matchedFeature) {
const value1 =
matchedFeature?.box?.find(i => i.type === 'a').value ?? 0;
feature.setAttribute('someValue', Number(value1));
// Repeated X times
}
})
})
}) If I do this, and try to reference "someValue" I get an error that it doesn't exist, so I tried to use "applyEdits" to update the value: this._layers[0].applyEdits({ updateFeatures: features })
.then((editsResult) => {
console.log('Edit Results');
console.log(editsResult);
})
.catch((error) => {
console.log("error = ", error);
}); Which works, but I still don't see my new attributes. Previous I was getting an error from applyEdits, but I resolved that problem! Can anyone see what I'm doing wrong? Thanks
... View more
11-16-2022
01:31 PM
|
0
|
5
|
1758
|
|
POST
|
Good Day I have a layer that which uses a valueExpression in the Unique Value Renderer to set it's style, giving me something like: I'm running into a problem where I need to know what colours / uniqueValueInfo from the Unique Value Renderer was set on to the map. How can I get this information? I tried running a query: queryAllFeatures(layer: FeatureLayer): Promise<Graphic[] | Error> {
return new Promise((r, j) => {
const query = {
where: '1=1',
outFields: ['*'],
returnGeometry: true
}
layer.queryFeatures(query).then((queryRes) => {
r(queryRes.features);
}).catch((error) => {
console.log(error);
j(null);
})
});
} But I can't seem to find the information in the output? I would imagine it's trivial to get the style information form the layer. Ideally I'd like to get a list of all styles / colours that are active. Is this possible? Thanks
... View more
11-03-2022
02:59 PM
|
0
|
1
|
787
|
|
POST
|
I changed the data so we only use 1 set of ~15 800 features and use the attributes to show the time values. Using this method I have ~70 attributes, but I can use "valueExpressions" to change the render setting, giving me almost instance response and feed back because I don't have to regrab the data, I only have to apply a new render setting. I've been extended this idea out, over the last several days, so I have a Unique Value Renderer with ~170+ settings in it, and then change the fields / "valueExpression" to change the view, which has been game changer. If anyone else is running into this problem, try to flatten the data out and use attributes instead of duplicating features if you can get away with it 🙂 Thanks for the suggestion, I was actually logging to update my progress, but you said exactly what I did, and it worked like a charm. Cheers
... View more
11-03-2022
02:44 PM
|
1
|
1
|
2726
|
|
POST
|
Good Day After looking through the widget list: https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html, I was wondering what's available to duplicate the Style, Filter and Properties widget available from ArcGIS Online: I assume those widgets not being in the list means I have to code something myself, is this true? Thanks
... View more
11-01-2022
10:00 AM
|
0
|
0
|
409
|
|
POST
|
Thanks for the suggestion but it's still a choppy mess, no matter how I breakdown the queries. Using pagination the year change code is now: if (changes.year.currentValue) {
const useDefinitionExpression = false;
if (useDefinitionExpression) {
this._view.map.layers.forEach((layer) => {
if (layer.type === 'feature') {
layer.definitionExpression = 'Year = ' + this._year;
}
})
} else {
const featureBreak = 10;
this._view.when(() => {
this._view.map.layers.forEach((layer) => {
if (layer.type === 'feature') {
this.queryFeatureCount(layer).then((featureCount: number) => {
const runQueryCode = true;
if (runQueryCode) {
const featureGroup = featureCount / featureBreak;
const featureSteps = [];
for (let i = 0; i <= featureCount; i += featureGroup) {
featureSteps.push({
start: Number(i.toFixed(0)),
end: Number((i + featureGroup - 1).toFixed(0))
})
}
const runFeatureStepLoop = true;
if (runFeatureStepLoop) {
this._map.removeAll();
featureSteps.forEach((step) => {
const query = {
start: step.start,
num: step.end,
where: 'Year = ' + this._year,
outFields: ["*"],
returnGeometry: true,
};
console.log('Query');
console.log(query);
layer.queryFeatures(query).then((queryResult) => {
try {
console.log('Adding New Features');
this._map.addMany(queryResult?.features);
} catch (error) {
console.log(error);
}
}).catch((queryError) => {
console.log('Error Querying Features');
console.log(queryError);
})
}) // END_FOREACH: Feature Steps
}
}
});
}
})
})
}
} Using "featureBreak" I can control how many queries are generated, but no matter what I set that to I run into the same problem. Right now that problem is a lot of shuddering and crashing. Apart from using this method, are there any considered best practices? I'm thinking we might have to use 1 layer / year to make this effective, because nothing I try seems to work. Thanks 😀
... View more
11-01-2022
09:13 AM
|
0
|
4
|
2748
|
|
POST
|
Thanks! I'm going to try and build a version of this to load the data in parts, that might solve my issue. I'll let you know if it works 🙂
... View more
10-31-2022
12:38 PM
|
0
|
0
|
2754
|
|
POST
|
Good Day I have a layer with ~790k features which is comprised of 15 800 features over 50 years, 15 800 * 50 = 790k. At any one point I only need to show 1 year or 15 800 features, and the field I need to filter on is called "Year". I'm using a Hosted Feature Layer and my current process is: 1. Grab the Feature Layer by Portal ID 2. Run a query on that layer give me all features 3. Use those features to build the render settings 4. Set the initial definitionExpression to the 2022, so I see the first batch of 15 800 features 5. Add that layer to the map: this._layers = [];
this._layers.push(new FeatureLayer({
portalItem: {
id: "<feature id>"
},
}))
this.buildRenderSetting().then((render) => {
if (_.isEmpty(this._year)) {
this._year = new Date().getFullYear();
}
this._layers[0].renderer = render;
if (this._year) {
this._layers[0].definitionExpression = 'Year = ' + this._year;
}
this._map.removeAll();
this._layers.forEach((layer) => {
this._map.add(layer);
})
}) This works great, and I get a nice map with the first 15 800 features, the problem is when I change the year! My code to handle the year change: if (changes.year.currentValue) {
console.log('Year Changed');
console.log(changes.year.currentValue);
this._view.when(() => {
this._view.map.layers.forEach((layer) => {
layer.definitionExpression = 'Year = ' + this._year;
})
})
}) When that code executes I'm getting a really latent update, that results in several tile errors, and the map locks up for a solid minute or two, before eventually updating. If I'm zoomed in to a small area ~200 features, the update is much faster, on the order of seconds. I've tried to use both FeatureFilter and FeatureEffect, but those run so slow that it's honestly unusable, and I can replicate the same experience with Effect / Filter on ArcGIS Online with this same layer. I'm using a UniqueRenderValue for the render setting, looks like: const uniqueRenderSettings = {
type: 'unique-value',
valueExpression: `When(${_valueExpression})`,
uniqueValueInfos: [{
value: <renderKey>,
label: <renderKey>,
symbol: {
type: <symbol>,
color: <colour>,
size: 12,
width: 3,
outline: {
width: 4,
color: <symbol>
}
}
}]
} Is there a way to properly handle this case? Thanks
... View more
10-28-2022
11:34 AM
|
0
|
7
|
2876
|
|
POST
|
Figured out the problem, you have to tell the setting it's a coded-value domain, the following code works: this._editWidgetConfiguration.push({
layer: layer,
formTemplate: {
elements: [{
type: "field",
fieldName: "layer",
label: "blah",
domain: {
codedValues: [
{name: "1", code: "1"},
{name: "2", code: "2"},
],
type: 'coded-value'
}
}]
}
}) Hopefully this helps someone else 🙂 Thanks
... View more
10-07-2022
08:14 AM
|
1
|
0
|
1172
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-25-2025 07:33 AM | |
| 1 | 03-18-2025 11:15 AM | |
| 1 | 10-07-2022 08:14 AM | |
| 1 | 08-25-2023 10:47 AM | |
| 1 | 02-23-2023 08:22 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-24-2025
07:12 AM
|