|
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
|
1057
|
|
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
|
502
|
|
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
|
1070
|
|
POST
|
Yes, this can be achieved in 4.x, primarily through the use of a RequestInterceptor. Basically, you'll use the interceptor to capture a print request, get the web map JSON from the request, and then cancel the request before it gets sent. This has several pieces. First, you should define a URL to a print service. Note that in our workflow, a request will never actually get sent to it, but it's best to specify a valid one: var printServiceURL = "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"; Next, somewhere near where your application starts (e.g. where the View is created), you would set up your interceptor: require(["esri/config"], function(esriConfig) {
esriConfig.request.interceptors.unshift({
urls: printServiceURL + "/execute",
before: function(params) {
var error = new Error("cancel");
error._webMapAsJSON = JSON.parse(params.requestOptions.query.Web_Map_as_JSON);
return error;
}
});
}); Elsewhere, you can create a function that accepts a reference to your view, and returns a Promise with the web map JSON: function getWebMapAsJSON(view) {
return new Promise(function(resolve, reject) {
require(["esri/rest/print", "esri/rest/support/PrintParameters", "esri/rest/support/PrintTemplate"], function(print, PrintParameters, PrintTemplate) {
var printTemplate = new PrintTemplate({
//whatever parameters desired
});
var printParameters = new PrintParameters({
//add other parameters as necessary
template: printTemplate,
view: view
});
print.execute(printServiceURL, printParameters).then(function(){}, function(e) {
resolve(e._webMapAsJSON);
});
});
});
} And then elsewhere you can call this function to get the JSON and do whatever you want with it: getWebMapAsJSON(view).then(function(webMapAsJSON) {
console.info(webMapAsJSON);
});
... View more
02-05-2025
10:13 AM
|
0
|
2
|
1089
|
|
POST
|
I see what you're talking about. I use SketchViewModel in our applications to support user-drawn geometries, and it doesn't exhibit this behavior. Perhaps your workflows are such that you could use it as an alternative to the Draw module.
... View more
02-03-2025
10:15 AM
|
1
|
0
|
1075
|
|
POST
|
You are very generous, especially with such excellent photography. I am already well-rewarded though, so no need to feel like you owe me anything. Have a great weekend!
... View more
01-17-2025
05:24 PM
|
0
|
0
|
1940
|
|
POST
|
Ok, I see the problem. In the "manageDynamicSymbology" function, you'll want to change this: if (featureSet.features.length === 0)
featureLayer.renderer = originalRenderer;
else { to this: if (featureSet.features.length === 0) {
if (featureLayer.renderer != originalRenderer)
featureLayer.renderer = originalRenderer;
else
ignoreRendererSet = false;
} else {
... View more
01-17-2025
02:14 PM
|
0
|
2
|
1949
|
|
POST
|
I took a closer look at your post from Monday, and think I see the problem. Here is what you posted reproduced for convenience: function zoomRoomUse (ids)
{
require ([
"esri/rest/query",
"esri/rest/support/Query",
"esri/layers/FeatureLayer",
"esri/views/layers/LayerView"
],
function (query, Query, FeatureLayer, LayerView)
{
roomsUseLayer.definitionExpression = roomsUseLayer.objectIdField + " IN(" + ids.join (",") + ")";
// console.log (roomsUseLayer.definitionExpression)
view.whenLayerView (roomsUseLayer).then (function (layerView)
{
var query = roomsUseLayer.createQuery ();
query.objectIds = [ids];
query.where = roomsUseLayer.definitionExpression;
roomsUseLayer.queryFeatures (query).then (function (results)
{
const features = results.features;
var geometry = features[0].geometry.extent.clone ();
for (var k = 0; k < features.length; k++) {
geometry = geometry.union (features[k].geometry.extent.clone ());
view.goTo (geometry).then (function ()
{
roomsUseLayer.visible = true;
manageDynamicSymbology (roomsUseLayer, view);
}).catch (function (error)
{
if (error.name != "view:goto-interrupted") {
console.error (error);
} else {
console.log ("Drawing");
}
});
}
});
});
});
} I think the main problem is that you're calling "manageDynamicSymbology" inside of a loop on line 27. The function manageDynamicSymbology should only ever be called one time, preferably when the layer is created. It never needs to be called again afterwards. For example: var layer = new FeatureLayer({
url: "https://my/url/MapServer/0",
id: "myLayerID"
});
manageDynamicSymbology(layer, view);
view.map.add(layer); Another problem is that you're also calling view.goTo inside the loop, but you want the loop to finish before calling that function. This way, you would only zoom one time to the full extent of the graphics. Here is the updated code: function zoomRoomUse(ids)
{
require ([
"esri/rest/query",
"esri/rest/support/Query",
"esri/layers/FeatureLayer",
"esri/views/layers/LayerView"
],
function (query, Query, FeatureLayer, LayerView)
{
roomsUseLayer.definitionExpression = roomsUseLayer.objectIdField + " IN(" + ids.join (",") + ")";
// console.log (roomsUseLayer.definitionExpression)
view.whenLayerView (roomsUseLayer).then (function (layerView)
{
var query = roomsUseLayer.createQuery ();
query.objectIds = [ids];
query.where = roomsUseLayer.definitionExpression;
roomsUseLayer.queryFeatures (query).then (function (results)
{
const features = results.features;
var geometry = features[0].geometry.extent.clone();
for (var k = 1; k < features.length; k++) {
geometry = geometry.union (features[k].geometry.extent.clone());
}
view.goTo (geometry).then (function ()
{
roomsUseLayer.visible = true;
}).catch (function (error)
{
if (error.name != "view:goto-interrupted") {
console.error (error);
} else {
console.log ("Drawing");
}
});
});
});
});
}
... View more
01-15-2025
11:16 AM
|
0
|
4
|
1966
|
|
POST
|
There is a possibility of an infinite loop occurring since setting the renderer will result in the "updating" property being set, and when the "updating" property is set to false, the process starts over again. However, that's what the "ignoreRendererSet" variable exists to prevent, and I don't see any immediate problem with it not doing its job. I would recommend using the browser's developer tools to add some breakpoints and step through the code to help determine where the infinite loop is occurring.
... View more
01-13-2025
06:06 PM
|
0
|
0
|
4694
|
|
POST
|
Yes, you can accomplish this by assigning a value to the suggestionTemplate property. You'll also want to set the outFields property to ensure that values for any fields you use in the template are being returned.
... View more
01-13-2025
02:43 PM
|
0
|
0
|
967
|
|
POST
|
It appears this will happen in cases where (1) a value exists, but no symbol has been defined for it, and (2) there is no default symbol defined. In this case, the feature wouldn't be rendered at all. To avoid the error, you could change the statement on line 34 from: if (defaultSymbol === null) { to if ((defaultSymbol === null) && (originalRenderer.defaultSymbol)) {
... View more
01-13-2025
02:34 PM
|
0
|
2
|
4727
|
|
POST
|
The "Find" sample is working fine, so looks like is still supported. Note that in version 4.20, these modules moved from esri/tasks to esri/rest (more info here). Perhaps you might need to update some references somewhere.
... View more
01-06-2025
02:50 PM
|
0
|
0
|
530
|
|
POST
|
I would recommend watching the updating property on the View. For example: view.watch("updating", function(newValue, oldValue, propertyName, target) {
activityIndicator.style.display = ((newValue) ? "inline" : "none");
});
... View more
01-06-2025
02:44 PM
|
0
|
0
|
629
|
|
POST
|
An alternate way would be to override the delete function: sketchViewModel.delete = function() { }; The above would cause nothing to happen when the delete function is called. If you needed to remove any graphics created by that module, you'd have to use some alternate means, like: sketchViewModel.layer.removeAll();
... View more
12-18-2024
09:22 AM
|
1
|
1
|
956
|
|
POST
|
Follow the instructions in this message, but change "api" in the URLs to "sdk".
... View more
12-12-2024
05:55 PM
|
0
|
0
|
2904
|
| 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 |