|
POST
|
Are you getting a new error, the same one, or nothing?
... View more
10-17-2023
01:48 PM
|
0
|
0
|
4611
|
|
POST
|
That's a compilation error, as opposed to a runtime error...so you'll need to make the compiler happy. You may need to import the SimpleRenderer, SimpleMarkerSymbol, and SimpleLineSymbol modules, and use their constructors to instantiate the renderer and its symbol instead of autocasting.
... View more
10-17-2023
11:42 AM
|
0
|
2
|
4624
|
|
POST
|
Yes, FeatureLayers will ignore the symbol properties on individual graphics. You'll likely need to set the renderer property on the FeatureLayer. For example: const featureLayer = await this.esri.FeatureLayer({
source: featuresArray,
objectIdField: "id",
title: "TestLayer",
renderer: {
type: "simple", // autocasts as new SimpleRenderer()
symbol: {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: "blue",
size: 10,
outline: { // autocasts as new SimpleLineSymbol()
width: 0.5,
color: "darkblue"
}
}
}
});
... View more
10-17-2023
11:04 AM
|
0
|
4
|
4632
|
|
POST
|
It may be because the ObjectID values are expected to be numeric, so you might need to use the following instead: attributes: {
id: parseInt(node.getAttribute("id"), 10)
} or you could also generate your own: var oid = 1;
for (const node of nodes) {
featuresArray.push({
geometry: {
longitude: node.getAttribute("lng"),
latitude: node.getAttribute("lat"),
type: "point"
},
attributes: {
id: oid++,
featureID: node.getAttribute("id")
}
});
}
... View more
10-17-2023
10:31 AM
|
0
|
6
|
4635
|
|
POST
|
I think the problem lies in the structure of the objects in your featuresArray. Perhaps try the following instead: for (const node of nodes) {
featuresArray.push({
geometry: {
longitude: node.getAttribute("lng"),
latitude: node.getAttribute("lat"),
type: "point"
},
attributes: {
id: node.getAttribute("id")
}
});
}
... View more
10-16-2023
07:00 PM
|
0
|
10
|
4664
|
|
POST
|
Somebody else can chime in if they know differently, but I don't think you'll find any other way. The FeatureLayer module just doesn't appear to have been designed for this kind of thing.
... View more
10-06-2023
09:55 AM
|
0
|
0
|
3903
|
|
POST
|
If you want the performance seen when using the view's graphics collection, but want a separate layer for the graphic, then it seems using a GraphicsLayer would be suitable: <html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
Update FeatureLayer using applyEdits() | Sample | ArcGIS Maps SDK for
JavaScript 4.27
</title>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.27/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.27/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/GraphicsLayer",
"esri/Graphic"
], (Map, MapView, GraphicsLayer, Graphic) => {
const graphic = new Graphic({ geometry: null });
const pointLayer = new GraphicsLayer({});
pointLayer.add(graphic);
const map = new Map({
basemap: "dark-gray-vector",
layers: [pointLayer]
});
const view = new MapView({
container: "viewDiv",
map: map,
center: [-117.18, 34.06],
zoom: 14
});
// draw point on pointer move
view.on("pointer-move", (event) => {
graphic.geometry = view.toMap(event);
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
10-05-2023
11:59 AM
|
0
|
2
|
3937
|
|
POST
|
In the case of the sample, "this" will refer to the window object since that's the context in which the call to bind occurs. Whatever you pass in the first argument of the bind function will be whatever "this" refers to inside the bound function.
... View more
10-04-2023
12:35 PM
|
0
|
1
|
2835
|
|
POST
|
I've found it to be working properly. In the sandbox for the "Popup actions" sample, you can change the code in the script tag beginning on line 27 to the following: require([
"esri/Map",
"esri/layers/FeatureLayer",
"esri/views/MapView",
"esri/geometry/geometryEngine",
"esri/core/reactiveUtils",
"esri/widgets/Popup"
], (Map, FeatureLayer, MapView, geometryEngine, reactiveUtils, Popup) => {
// Create the Map
const map = new Map({
basemap: "gray-vector"
});
// Create the MapView
const view = new MapView({
container: "viewDiv",
map: map,
center: [-117.08, 34.1],
zoom: 11,
popup: new Popup({})
});
/*************************************************************
* The PopupTemplate content is the text that appears inside the
* popup. Bracketed {fieldName} can be used to reference the value
* of an attribute of the selected feature. HTML elements can be
* used to provide structure and styles within the content.
**************************************************************/
// Add this action to the popup so it is always available in this view
const measureThisAction = {
title: "Measure Length",
id: "measure-this",
image:
"https://developers.arcgis.com/javascript/latest/sample-code/popup-actions/live/Measure_Distance16.png"
};
const template = {
// autocasts as new PopupTemplate()
title: "Trail run",
content: "{name}",
actions: [measureThisAction]
};
const featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/TrailRuns/FeatureServer/0",
popupTemplate: template
});
map.add(featureLayer);
// Execute each time the "Measure Length" is clicked
function measureThis() {
const geom = view.popup.selectedFeature.geometry;
const initDistance = geometryEngine.geodesicLength(geom, "miles");
const distance = parseFloat(
Math.round(initDistance * 100) / 100
).toFixed(2);
view.popup.content =
view.popup.selectedFeature.attributes.name +
"<div style='background-color:DarkGray;color:white'>" +
distance +
" miles.</div>";
}
// Event handler that fires each time an action is clicked.
reactiveUtils.on(
() => view.popup,
"trigger-action",
(event) => {
// Execute the measureThis() function if the measure-this action is clicked
if (event.action.id === "measure-this") {
measureThis();
}
}
);
view.popup.on("trigger-action", function(target, event) {
const featureLocation = target.location;
console.info(featureLocation.x + ", " + featureLocation.y);
console.info(event.action.title);
console.info(target);
console.info(event);
}.bind(this, view.popup));
}); In the code above, changes to the original are found on lines 6-8, 19-20, and (primarily) 77-84. After the sample is refreshed, clicking on a feature and then the "Measure Length" action in the popup produces the following in the console, showing the expected output: If I had to guess as to why it isn't working for you, perhaps the call to bind was not made correctly.
... View more
10-04-2023
10:43 AM
|
1
|
3
|
2841
|
|
POST
|
The API doesn't provide a means for doing what you're looking for, but that doesn't mean you can't pull it off. Although the documentation says a String is expected for suggestionTemplate, you can presently get away with an object that has simply has a "replaceAll" function. Since such an implementation isn't according to the documentation, it might not work in future releases, but it does work now (in 4.27). For example, with the senators sample you referred to, the critical part of the code (i.e. where suggestionTemplate is defined) could look something like this: sources: [
{
//etc
suggestionTemplate: {
replaceAll: function(a, b) {
var piecesIn = [
["{Name}", ""],
["Party: {Party}", "Party: "]
];
var piecesOut = [];
piecesIn.forEach(function(pieceIn) {
var pieceOut = pieceIn[0].replaceAll(a, b);
if (pieceOut !== pieceIn[1])
piecesOut.push(pieceOut);
});
if (piecesOut.length === 0)
return "";
else if (piecesOut.length === 1)
return piecesOut[0];
else
return piecesOut.join(", ");
}
}
//etc
}
] In your case, you would just replace the definition of "piecesIn" with something like this: var piecesIn = [
["Name: {KNOWNAS}", "Name: "],
["Room: {SHORTNAME}", "Room: "],
["Phone: {PHONE}", "Phone: "],
["Cell: {MOBILE}", "Cell: "],
["{WORKSITE} ", " "]
];
... View more
10-03-2023
05:55 PM
|
0
|
0
|
1727
|
|
POST
|
According to this page, this is resolved in the upcoming 4.28 release; search (Ctrl-F) for "Esri Community - 1308220".
... View more
10-03-2023
09:13 AM
|
1
|
0
|
6344
|
|
POST
|
Yes, you can use it. However, since it's not in the documentation, that means this module can be changed or removed in a future release without any notice.
... View more
10-02-2023
10:17 AM
|
0
|
0
|
1518
|
|
POST
|
There doesn't presently appear to be any way to avoid this. The SketchViewModel module has a dependency on SnappingManager, as well as a couple other snapping modules, and the rest of it likely cascades from there. Chances are, if you temporarily commented out your requirement for SketchViewModel and loaded your application, you wouldn't see all those snapping modules being brought in.
... View more
09-27-2023
10:21 AM
|
0
|
0
|
1345
|
|
POST
|
There doesn't appear to be a way of doing so according to the documentation, but this presently works: const layerList = new LayerList({
view: view,
listItemCreatedFunction: function(event){
const item = event.item;
// displays the legend for each layer list item
item.panel = {
content: "legend"
};
var handle = item.panel.watch("className", function(newValue, oldValue, propertyName, target) {
if (target._legend) {
handle.remove();
handle = null;
var legend = target._legend;
alert("got legend: " + legend.id);
}
});
}
});
... View more
09-25-2023
11:26 AM
|
1
|
1
|
1180
|
|
POST
|
You can also do this as well: popup.on("trigger-action", function(target, event) {
const featureLocation = target.location;
}.bind(this, popup));
... View more
09-22-2023
04:41 PM
|
0
|
5
|
2912
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-19-2024 10:37 AM | |
| 1 | 03-31-2026 02:34 PM | |
| 1 | 12-09-2025 09:35 AM | |
| 2 | 12-09-2025 09:06 AM | |
| 1 | 11-26-2025 12:29 PM |