Hi, I am new to community.
I'm reaching out to the ArcGIS community for support regarding an issue I'm experiencing with the Editor widget (JS API 4.25) and FeatureLayer. I'm trying to use the Editor widget to display military symbols, which I have created using a third-party library, on FeatureLayer.
The problem is that while the symbols I created from a JSON file are displayed correctly on the layer but on Editor widget, only defaultSymbol is being displayed. I'm uncertain about how to interpret and resolve this issue. To provide some context, I have included a snippet of the relevant code below:
Thanks in advance.
ps: please ignore lineLayerMilitary.
var situation = {"name":"Layer","type":"FeatureCollection",
"crs": {"type": "name","properties": {"name": "EPSG:4326"}},
"features":[
{"type":"Feature","geometry":{"type":"Point","coordinates":[13.9264527063343,56.2888907165595]},"properties":{"SIDC":"SFGPU------E***","name":"1.C2 komp","fullname":"1.C2 komp/FTS/INSS","command":"FTS"}}
,{"type":"Feature","geometry":{"type":"Point","coordinates":[19.1604869967705,65.5966818958909]},"properties":{"SIDC":"SFGPUCRV---F***","name":"1.Jbat","fullname":"1.Jbat/INSS","command":"INSS"}}
,{"type":"Feature","geometry":{"type":"Point","coordinates":[17.0825282191617,59.6410393541284]},"properties":{"SIDC":"SFGPUUMSE--F***","name":"1.TKbat","fullname":"1.TKbat/INSS","command":"INSS"}}]}
var unknown = new ms.Symbol("SFGPUUMSE--F***", { size: 15, square: true });
var unknownUnit = new PictureMarkerSymbol({
url: unknown.asCanvas(3).toDataURL(),
width: Math.max(unknown.getSize().width),
height: Math.max(unknown.getSize().height)
});
let uvrenderer = new UniqueValueRenderer({
field: "name",
defaultSymbol: unknownUnit
});
var graphics = situation.features.map((feature, i) => {
var unit = new ms.Symbol(feature.properties.SIDC, { size: 15, square: true });
var unitSymbol = new PictureMarkerSymbol({
url: unit.asCanvas(3).toDataURL(),
width: Math.max(unit.getSize().width),
height: Math.max(unit.getSize().height)
});
uvrenderer.addUniqueValueInfo(feature.properties.name,unitSymbol)
return {
geometry: new Point({
x: feature.geometry.coordinates[0],
y: feature.geometry.coordinates[1]
}),
symbol: unitSymbol,
attributes: {
ObjectID: i,
name: feature.properties.name,
SIDC: feature.properties.SIDC,
}
};
});
const pointLayerMilitary = new FeatureLayer({
id:'pointLayerMilId',
outFields: ["*"],
templates : [{
"name" : "Military",
"prototype" : {
"attributes" : {
title:null
}
}}],
source:graphics,
visible:true,
geometryType: "point",
fields: [{name: "ObjectID",alias: "ObjectID",type: "oid"}
,{name: "name",alias: "Name",type: "string"}
,{name: "SIDC",alias: "SIDC",type: "string"}
,{name: "command",alias: "Command",type: "string"}],
objectIdField: "ObjectID",
renderer: uvrenderer
});
this._view.map.add(pointLayerMilitary);
const layerInfos = [{layer: lineLayerMilitary,pointLayerMilitary}];
const editorMil = new Editor({
label:'Military Symbology',
headingLevel:2,
visibleElements: {snappingControls: false},
viewModel: new EditorVM({
layerInfos:layerInfos,
featureTemplatesViewModel: new FeatureTemplatesVM({
layers: [lineLayerMilitary,pointLayerMilitary],
}),
view: this._view
}),
});
this._view.ui.add(editorMil, "bottom-right");