|
POST
|
Good Day I found a solution! I was previous performing a featureEffect query to show and hide layers, setting excluded layers to opacity 0%. This was working great until yesterday when we noticed I could still interact with the features (my fault, I should have thought about that!). I decided to move from the featureEffect query to the layerView filter query, and now all PrintTasks are showing up with legends intact. It seems for some odd reason that the “featureEffect” was causing the problem. Hopefully this can help others in the future! Thanks for your help.
... View more
02-23-2023
08:22 AM
|
1
|
2
|
2921
|
|
POST
|
Thanks for the suggestion, I'm kind of baffled as to why I didn't think of that myself. The “featureCollection” object is missing when the legend isn't present. When I don't have the “featureCollection”, I have “imageData”, and I think that's what is causing the problem. Should I be adding in LegendLayers into the Print Parameters? https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-LegendLayer.html If so, what do I pass for layerId and subLayerId? I would assume I get the layerId with: const legendLayers = []
this._view.map.layers.forEach((layer) => {
let legendLayer = new LegendLayer();
legendLayer.layerId = layer.id;
legendLayer.subLayerId = [] // NOTE: I don't know what to pass for this
}); I already to do this, but I keep getting three boxes, Red, Green and Blue showing up, which I think it due to incorrectly assembling the legend layers array. If run a featureEffect filter, or manually replace the render setting on a feature layer with layer.renderer = newRenderSetting, will that cause an issue? Thanks!
... View more
02-16-2023
10:28 AM
|
0
|
0
|
2952
|
|
POST
|
If it matters, this is buildRenderSetting private buildRenderSettingForLayer(geometryType: string = 'polyline'): UniqueValueRenderer {
let renderSetting;
if (this.gisFlag) {
if (geometryType === 'point' && this.tabIndex === 0) {
// NOTE: The first tab in the GIS Page is a "Picture Marker"
renderSetting = this.render.getUniqueRenderSetting(`picture-point`);
} else {
// NOTE: Handle lines / polygons
renderSetting = this.render.getUniqueRenderSetting(geometryType);
}
} else {
// NOTE: Handle lines / polygons
renderSetting = this.render.getUniqueRenderSetting(geometryType);
}
if (this.gisFlag) {
const gisFieldInformation = this.whichGISField();
renderSetting.field = gisFieldInformation.field;
renderSetting.valueExpression = null;
if (gisFieldInformation.valueExpression !== '') {
renderSetting.field = '';
renderSetting.valueExpression = gisFieldInformation.valueExpression;
this.hostLayerState = this.render.getLegend(gisFieldInformation.legendType);
this.hostLayerState.forEach((layerState) => {
layerState.field = gisFieldInformation.legendField;
})
}
} else if (this.performance) {
if (!this._year) {
this._year = 2022;
}
renderSetting.field = '';
const valueExpression =
this.render.getValueExpression('CONDITION');
renderSetting.valueExpression =
valueExpression.replaceAll('FIELD_REPLACE_TEXT', `$feature.F${this._year}`);
} else if (this._capitalPlan || this._alignment) {
renderSetting.field = `F${this._year}`;
renderSetting.valueExpression = '';
}
console.log('Render Setting - Build Render Setting');
console.log(_.cloneDeep(renderSetting));
return renderSetting;
}
... View more
02-15-2023
07:05 AM
|
0
|
0
|
2983
|
|
POST
|
Good Day API Version 4.25.5 "@arcgis/core": "4.25.5",
"@esri/arcgis-rest-auth": "3.6.0",
"@esri/arcgis-rest-feature-layer": "3.6.0",
"@esri/arcgis-rest-portal": "3.6.0",
"@esri/arcgis-rest-request": "3.6.0",
"@esri/arcgis-rest-types": "3.6.0",
"@esri/calcite-components": "1.0.2", All the layers are Feature Layers, here is the way they're set up: private buildFeatureSettings(geometryType: string, data: any, metaLayer: boolean = false): any {
const layerLabelClass = new LabelClass({
labelExpressionInfo: {expression: '$feature.label'},
symbol: {
type: 'text',
color: 'black',
haloSize: 1,
haloColor: 'white'
}
});
const renderSetting = this.buildRenderSettingForLayer(geometryType);
return {
fields: metaLayer ? this._metaFields : this._fields,
geometryType: geometryType,
globalIdField: 'assetSectionId',
id: metaLayer ? `meta-${data[0].attributes.layerId}` : this.generateUniqSerial(),
labelingInfo: [layerLabelClass],
objectIdField: 'ObjectID',
outFields: ['*'],
renderer: renderSetting,
source: data,
title: '',
visible: true
}
} “renderSetting” is the same for all layers, it's ~160 Unique Value Render Settings. One thing I have noticed is that the layers which don't use “valueExpressions” are always showing up, I only see this odd behaviour when I use “valueExpressions”, but it's not constant. Any help would be greatly appreciated 🙂 Thanks
... View more
02-15-2023
07:03 AM
|
0
|
0
|
2983
|
|
POST
|
Good Day I have a weird issue where my PrintTask outputs are missing legend, sometimes, but not others, and I can't find a pattern as to why. I have a unique value render setting with ~160 different values in it, and on most of the maps I use a valueExpression to set the renderer. If I take two maps which use the same valueExpression, literally the same one, and compare them, one will generate with legends, and the other won't. Map 1: Map 2: The valueExpression: When($feature.aType == 3 && $feature.ci > -10 && $feature.ci <= 40, 'condition_3_Crititcal',$feature.aType == 3 && $feature.ci > 40 && $feature.ci <= 50, 'condition_3_Poor',$feature.aType == 3 && $feature.ci > 50 && $feature.ci <= 65, 'condition_3_Fair',$feature.aType == 3 && $feature.ci > 65 && $feature.ci <= 90, 'condition_3_Good',$feature.aType == 3 && $feature.ci > 90 && $feature.ci <= 99, 'condition_3_Excellent',$feature.aType == 3 && $feature.ci > 99 && $feature.ci <= 100, 'condition_3_Perfect',$feature.aType == 3 && $feature.ci > -10 && $feature.ci <= 0, 'condition_3_Not Defined','condition_Not Defined') That is the valueExpression shared by both maps, the first will generate a legend, the second won't. This is my print function: public printMap(): void {
const titleText = 'Map: ';
/* let layerLegend = new LegendLayer();
let layerIds = [];
this._view.map.layers.forEach((layer) => {
layerIds.push(layer.id);
})
layerLegend.layerId = "layer1";
layerLegend.subLayerIds = layerIds;
legendLayers: [layerLegend],
*/
const template = new PrintTemplate({
format: 'pdf',
layout: 'a4-landscape',
layoutOptions: {
authorText: 'Blah',
titleText
},
});
const params = new PrintParameters({
view: this._view,
template,
});
//
// NOTE: Start the print progress spinner
//
this.printProgress = true;
const printURL = 'https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task';
PrintTask.execute(printURL, params).then((result) => {
//
// NOTE: Stop the spinner and open the print output
// into a new tab.
//
this.printProgress = false;
this.forceChange();
window.open(result.url);
}, () => {
this.alert.errorDialog('Print Error', 'Please try again or contact support!');
this.printProgress = false;
this.forceChange();
});
} Is there any reason for this behaviour? I'm I missing something in the PrintTemplate or PrintParameters? On a strange note, I don't use a valueExpression, I always get a legend on the print output: I suspect the problem has to do with the use of the valueExpression, so is there a way to pass my legend / layer information directly to the print task? Thanks
... View more
02-14-2023
02:21 PM
|
0
|
8
|
3068
|
|
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
|
986
|
|
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
|
1063
|
|
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
|
778
|
|
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
|
685
|
|
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
|
2141
|
|
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
|
2166
|
|
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
|
2185
|
|
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
|
2232
|
|
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
|
947
|
| 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 |
03-13-2026
07:55 AM
|