|
POST
|
I have a map service published to ArcGIS Server whose spatial reference is WGS 84 UTM Zone 6N (WKID 32606). One of the layers in the service has labeling information defined, and the labelExpressionInfo.expression is set to: Round(Length(Geometry($feature),"feet"),2). I load this layer into a map as a 2D FeatureLayer. The spatial reference of the map is Web Mercator (WKID 3857). The data being retrieved from the server is returned by ArcGIS Server projected into Web Mercator (WKID 3857). Nonetheless, labels do not show up, and the following error appears in the console: Cannot work with geometry in this spatial reference. It is different to the execution spatial reference. This should not be happening because the data queried from the service is already in the Web Mercator projection. The problem is that the API, when processing the FeatureSets returned from the server, assigns the layer's spatial reference (WKID 32606) to the data, even though the coordinates are Web Mercator. The most convenient place I've found to insert a fix for this is in the esri.views.2d.layers.features.support.FeatureSetReaderJSON module, in the "fromFeatureSet" method. The published implementation looks like this: static fromFeatureSet(a, f) {
a = q.convertFromFeatureSet(a, f.objectIdField);
return l.fromOptimizedFeatureSet(a, f)
} The "a" parameter is the FeatureSet returned from the query, still in JSON format. The "f" parameter is an object containing various settings from the layer, including the spatial reference. Basically, I clone the "f" object, and set its spatial reference to the same as the FeatureSet: static fromFeatureSet(a, f) {
var g = {};
Object.getOwnPropertyNames(f).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(f))).forEach(function(h) {
if (typeof f[h] != "function")
g[h] = f[h];
});
if (a.spatialReference)
g.spatialReference = f.spatialReference.constructor.fromJSON(a.spatialReference);
f = g;
a = q.convertFromFeatureSet(a, f.objectIdField);
return l.fromOptimizedFeatureSet(a, f)
} As can be seen, I've added lines 2-9, and everything else is the same. With this fix in place, no errors occur and the labels show up properly. I was using 4.31 for this, but other versions may be affected as well.
... View more
04-07-2025
04:51 PM
|
0
|
3
|
568
|
|
POST
|
Have you considered extending the Accessor class? See also https://developers.arcgis.com/javascript/latest/implementing-accessor/
... View more
03-25-2025
07:21 PM
|
2
|
3
|
762
|
|
POST
|
Yes, you can create a legend as a child of any pre-existing element. The following example shows getting a reference to an existing element via document.getElementById: const legend = new Legend({
view: view,
container: document.getElementById("sidebar")
}); In your example, the "sidebar" element needs to be created and added to the document before creating the Legend though.
... View more
03-25-2025
06:31 PM
|
2
|
1
|
490
|
|
POST
|
Ok, since there's no payload tab, I see what you were saying earlier about the tab going away. Unfortunately, without it, it doesn't give us much to go on. It makes me wonder if the request is being sent without the features being edited because if I understand it correctly, the Payload tab should still be there even if a POST request results in an HTTP 500. This one may need Esri Technical Support if you have access to it.
... View more
03-13-2025
01:44 PM
|
0
|
1
|
736
|
|
POST
|
That shows the request for the query option that preceded applyEdits, but I would need to see the details for the applyEdits request. That is, you'd need to double click the row for applyEdits.
... View more
03-13-2025
01:14 PM
|
0
|
3
|
739
|
|
POST
|
Maybe if you can post a screenshot of the payload tab for a request that works (single) and a request that fails (multiple) it might help reveal if the problem is on the application side.
... View more
03-13-2025
11:50 AM
|
0
|
5
|
742
|
|
POST
|
If you double-click on a request in the Network log, you'll see an additional set of tabs with information about the request...the Payload tab is in there.
... View more
03-12-2025
11:45 AM
|
0
|
10
|
748
|
|
POST
|
That looks fine as far as I can tell. You might want to check out the Network Tab of the developer tools and look into the details of the request sent to applyEdits. Particularly, check out the payload to make sure everything looks proper in there.
... View more
03-11-2025
04:21 PM
|
0
|
1
|
712
|
|
POST
|
A few things to check: 1) Make sure this data is going to the right layer in the service. 2) Make sure all the fields are named correctly and exist in the service. Field names are case sensitive. 3) The OBJECTID field shouldn't be included in the attributes you capture from the form. Lines 9 and 10 in the code I wrote are supposed to strip it out if it's present. I suppose the server could generate an error if multiple update records were supplied with the same objectID values. For reference, since it's on a different page now, here's the code where you capture the values from the form: editRoom.OBJECTID = Number (roomObjectID)
editRoom.ADA = document.getElementById ('roomDetails-ADA').value;
editRoom.CAPACITY = document.getElementById ('roomDetails-CAPACITY').value;
editRoom.SPACETYPECAT1KEY = document.getElementById ('roomDetails-SPACETYPECAT1KEY').value;
editRoom.SPACETYPECAT2KEY = document.getElementById ('roomDetails-SPACETYPECAT2KEY').value;
editRoom.SPACEUSECAT1KEY = document.getElementById ('roomDetails-SPACEUSECAT1KEY').value;
editRoom.SPACEUSECAT2KEY = document.getElementById ('roomDetails-SPACEUSECAT2KEY').value;
editRoom.DESCRIPTION = document.getElementById ('roomDetails-DESCRIPTION').value;
editRoom.CAPACITY = document.getElementById ('roomDetails-CAPACITY').value;
editRoom.ASSIGNABLE = document.getElementById ('roomDetails-ASSIGNABLE').value;
editRoom.NOTES = document.getElementById ('roomDetails-NOTES').value;
editRoom.USABLE = document.getElementById ('roomDetails-USABLE').value;
... View more
03-07-2025
05:31 PM
|
0
|
3
|
732
|
|
POST
|
Are you able to log into ArcGIS Server Manager for that instance? If so, the logs may contain more information.
... View more
03-07-2025
12:32 PM
|
0
|
6
|
771
|
|
POST
|
My bad, line 16 above should be: featureLayer.applyEdits({updateFeatures:featureSet.features}).then( I'll change it in that post too.
... View more
03-07-2025
12:08 PM
|
0
|
8
|
776
|
|
POST
|
If you want to set multiple features to have the same attribute values, you could do so with a function like this: function _applyUpdates (featureLayer, attributes, objectIds)
{
return new Promise(function(resolve, reject) {
var query = featureLayer.createQuery();
query.returnGeometry = true;
query.objectIds = objectIds;
featureLayer.queryFeatures().then(function(featureSet) {
if (attributes.hasOwnProperty(featureLayer.objectIdField))
delete attributes[featureLayer.objectIdField];
featureSet.features.forEach(function(feature) {
Object.assign(feature.attributes, attributes);
});
featureLayer.applyEdits({updateFeatures:featureSet.features}).then(
function (results)
{
console.log (results);
resolve();
}, // callback
function (error)
{
console.log ('ERROR!', error);
reject(error);
}// errorback
);
});
});
} You would then determine the records you want to update, and create an Array of their objectID values: var objectIds = [1,2,3,4,5]; Then you could call the function: _applyUpdates(roomsTable, editRoom, objectIds);
... View more
03-07-2025
09:56 AM
|
0
|
10
|
790
|
|
POST
|
I rarely use 3.x these days, but I remember running into problems where only one feature would show. In those cases, it was always related to the OBJECTID field - either there wasn't one, or it was configured incorrectly. It looks like that may be what's going on here. On line 13, you define the objectID field as "OBJECTID". However, looking at the attributes, the field name is all lower-case "objectid". However, field names are case-sensitive. If you change the definition on line 13 to "objectid", it may solve your problem.
... View more
02-26-2025
02:47 PM
|
1
|
0
|
516
|
|
POST
|
A bug in the 4.31 SDK (and possibly previous versions) causes trouble when moving Circle geometries via the SketchViewModel. Basically, if you move a circle graphic once, it's fine. But if you move it after that, it will "jump back" to its original location and then move in relation to the mouse. To illustrate, this can be reproduced with the following steps: 1) Open the sandbox for the "Sketch temporary geometries" sample. 2) Replace the contents of the script tag found on line 21 with the following: require([
"esri/Color",
"esri/Graphic",
"esri/Map",
"esri/geometry/Circle",
"esri/geometry/Point",
"esri/geometry/Polygon",
"esri/layers/GraphicsLayer",
"esri/symbols/SimpleFillSymbol",
"esri/views/MapView",
"esri/widgets/Sketch/SketchViewModel",
], (Color, Graphic, Map, Circle, Point, Polygon, GraphicsLayer, SimpleFillSymbol, MapView, SketchViewModel) => {
const graphicsLayer = new GraphicsLayer();
const map = new Map({
basemap: "topo-vector",
layers: [graphicsLayer]
});
const view = new MapView({
container: "viewDiv",
map: map,
zoom: 18,
center: [139.5716, 35.6964]
});
view.when(() => {
var sketchViewModel = new SketchViewModel({
layer: graphicsLayer,
view: view
});
var extent = view.extent;
var yDiff = extent.height / 4;
var xDiff = extent.width / 4;
var circle1 = new Circle({
center: new Point({x:extent.xmin + xDiff, y:extent.ymax - yDiff, spatialReference:extent.spatialReference}),
geodesic: true,
numberOfPoints: 100,
radius: 50,
radiusUnit: "meters"
});
var circle2 = new Circle({
center: new Point({x:extent.xmax - xDiff, y:extent.ymin + yDiff, spatialReference:extent.spatialReference}),
geodesic: true,
numberOfPoints: 100,
radius: 50,
radiusUnit: "meters"
});
var graphic1 = new Graphic({
geometry: circle1,
attributes: [],
symbol: new SimpleFillSymbol({color:new Color("red"), style:"solid"})
});
var graphic2 = new Graphic({
geometry: Polygon.fromJSON(circle2.toJSON()),
attributes: [],
symbol: new SimpleFillSymbol({color:new Color("green"), style:"solid"})
});
graphicsLayer.add(graphic1);
graphicsLayer.add(graphic2);
});
}); 3) Click the "Refresh" button at the top-right of the map. 4) Click the red circle on the map to activate editing mode. 5) Drag the red circle to a new location (this works fine). 6) Now, attempt to drag it to a new location. It "jumps back" to its original location, and then updates itself relative to that location according to your mouse movements. All subsequent movements do this as well. In contrast, the green circle does not exhibit this behavior and you can move it around normally. This is because the green circle is not an instance of Circle, but an instance of Polygon. See line 60 above, where an object created as a Circle is "converted" to an instance of Polygon. Therefore, this is a current workaround for this problem.
... View more
02-07-2025
11:56 AM
|
0
|
0
|
261
|
|
POST
|
@Arne_Gelfert wrote: I have to wonder why something so simple had to become so complicated. The logic that generates the web map JSON can be seen in the esri/rest/print module, but due to the way it's encapsulated, it's impossible to get to in the same manner as 3.x.
... View more
02-05-2025
02:24 PM
|
0
|
0
|
463
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 hours ago | |
| 1 | 4 hours ago | |
| 1 | 2 weeks ago | |
| 3 | 2 weeks ago | |
| 1 | 10-02-2025 01:14 PM |